mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
Initialize CLEANUP_* stack variables with NULL in various places.
Code like: CLEANUP_FREE char *buf; /* some code which might return early */ buf = malloc (10); is a potential bug because the free (*buf) might be called when buf is an uninitialized pointer. Initialize buf = NULL to avoid this. Several of these are bugs, most are not bugs (because there is no early return statement before the variable gets initialized). However the compiler can elide the initialization, and even if it does not the performance "penalty" is miniscule, and correctness is better.
This commit is contained in:
@@ -280,7 +280,7 @@ do_internal_lxattrlist (const char *path, char *const *names)
|
||||
|
||||
for (k = 0; names[k] != NULL; ++k) {
|
||||
void *newptr;
|
||||
CLEANUP_FREE char *pathname;
|
||||
CLEANUP_FREE char *pathname = NULL;
|
||||
|
||||
/* Be careful in this loop about which errors cause the whole call
|
||||
* to abort, and which errors allow us to continue processing
|
||||
|
||||
Reference in New Issue
Block a user