mirror of
https://github.com/systemd/systemd.git
synced 2025-02-28 05:57:33 +03:00
scsi_id: use _cleanup_free_ on buffer allocated by get_file_options
This simplifies the code a bit and hopefully fixes Coverity finding CID 1382966. There was not actually a resource leak here (Coverity seemed to be confused by thinking log_oom() could actually return 0), but the fix doesn't hurt and should make this code more resilient to future refactorings. Tested: builds fine, manually called scsi_id, seems to work ok.
This commit is contained in:
parent
6cdf635de0
commit
3ad9705824
@ -164,7 +164,7 @@ static int get_file_options(struct udev *udev,
|
||||
const char *vendor, const char *model,
|
||||
int *argc, char ***newargv)
|
||||
{
|
||||
char *buffer;
|
||||
_cleanup_free_ char *buffer = NULL;
|
||||
_cleanup_fclose_ FILE *f;
|
||||
char *buf;
|
||||
char *str1;
|
||||
@ -295,14 +295,13 @@ static int get_file_options(struct udev *udev,
|
||||
(*newargv)[c] = buffer;
|
||||
for (c = 1; c < *argc; c++)
|
||||
(*newargv)[c] = strsep(&buffer, " \t");
|
||||
buffer = NULL;
|
||||
}
|
||||
} else {
|
||||
/* No matches */
|
||||
retval = 1;
|
||||
}
|
||||
}
|
||||
if (retval != 0)
|
||||
free(buffer);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user