Details
-
Bug
-
Status: Closed (View Workflow)
-
Minor
-
Resolution: Done
-
1.1.0, 1.2.0, 1.3.0, 1.4.0
-
None
-
2016-12
Description
If realloc fails it returns NULL. Thus, in a situation like
void* p = ...;
|
...;
|
p = realloc(p, ...);
|
if realloc fails, the previously allocated memory will leak. Realloc must be used like:
void* p = ...;
|
...;
|
void* tmp = realloc(p, ...);
|
 |
if (tmp) {
|
p = tmp;
|
} else {
|
...
|
}
|