mirror of
https://github.com/TheAlgorithms/C.git
synced 2026-07-10 19:16:54 +00:00
[PR #1143] [MERGED] fix: Removed double / unintended free #1715
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/TheAlgorithms/C/pull/1143
Author: @enzoveroneze
Created: 11/9/2022
Status: ✅ Merged
Merged: 11/10/2022
Merged by: @Panquesito7
Base:
master← Head:patch-2📝 Commits (1)
f0d7ddcRemoved double / unintended free📊 Changes
1 file changed (+1 additions, -2 deletions)
View changed files
📝
data_structures/dynamic_array/dynamic_array.c(+1 -2)📄 Description
Description of Change
Call to free() after realloc() removed, avoiding undefined behavior.
The call to realloc() already frees the previously allocated memory if necessary.
By the man page of realloc(): "f the area pointed to was moved, a free(ptr) is done.",
and free(): "If free(ptr) has already been called before, undefined behavior occurs.".
Checklist
Notes: Removed call to free() after realloc()
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.