mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-02 01:18:26 +03:00
clang: close file on memory alloc error path
This commit is contained in:
parent
ebc5c0cb1d
commit
40010e3eb8
@ -406,7 +406,7 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
|||||||
buffer_size = LINE_SIZE;
|
buffer_size = LINE_SIZE;
|
||||||
if (!(buffer = malloc(buffer_size))) {
|
if (!(buffer = malloc(buffer_size))) {
|
||||||
log_error("Failed to malloc line buffer.");
|
log_error("Failed to malloc line buffer.");
|
||||||
return 0;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (fgets(buffer, (int) buffer_size, fp))
|
while (fgets(buffer, (int) buffer_size, fp))
|
||||||
@ -419,12 +419,11 @@ static int _parse_file(struct dm_task *dmt, const char *file)
|
|||||||
r = 1;
|
r = 1;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
memset(buffer, 0, buffer_size);
|
if (buffer) {
|
||||||
#ifndef HAVE_GETLINE
|
memset(buffer, 0, buffer_size);
|
||||||
free(buffer);
|
free(buffer);
|
||||||
#else
|
}
|
||||||
free(buffer);
|
|
||||||
#endif
|
|
||||||
if (file && fclose(fp))
|
if (file && fclose(fp))
|
||||||
log_sys_debug("fclose", file);
|
log_sys_debug("fclose", file);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user