Actions
Bug #1062
closed
VJ
bad realloc usage pattern
Bug #1062:
bad realloc usage pattern
Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
Affected Versions:
Effort:
Difficulty:
Label:
Description
In quite a few places, we have the following pattern:
ptr = realloc(ptr, newsize);
However, if realloc fails we're in trouble: "If realloc() fails the original block is left untouched; it is not freed or moved." (man realloc)
As we then overwrite the pointer to NULL, we've lost our reference to the original allocation, leading to memory leaking.
Actions