Project

General

Profile

Actions

Bug #1062

closed

bad realloc usage pattern

Added by Victor Julien over 10 years ago. Updated almost 8 years ago.

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

Also available in: Atom PDF