mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Set dp to NULL when we free it, and tree a NULL dp as an error
condition. This should prevent a double free. In addition, prevent a leak by freeing dp each loop and when we're done. CID: 1383577 Sponsored by: Netflix
This commit is contained in:
parent
63b5669494
commit
167b7a41ff
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=327574
|
@ -663,6 +663,7 @@ path_to_dp(struct gmesh *mesh, char *path, efidp *dp)
|
|||
free(rp);
|
||||
if (rv != 0) {
|
||||
free(*dp);
|
||||
*dp = NULL;
|
||||
}
|
||||
return (rv);
|
||||
}
|
||||
|
|
|
@ -143,10 +143,13 @@ unix_to_efi(void)
|
|||
char *walker;
|
||||
int rv;
|
||||
|
||||
dp = NULL;
|
||||
while (fgets(buffer, sizeof(buffer), stdin)) {
|
||||
walker= trim(buffer);
|
||||
free(dp);
|
||||
dp = NULL;
|
||||
rv = efivar_unix_path_to_device_path(walker, &dp);
|
||||
if (rv != 0) {
|
||||
if (rv != 0 || dp == NULL) {
|
||||
errno = rv;
|
||||
warn("Can't convert '%s' to efi", walker);
|
||||
continue;
|
||||
|
@ -158,6 +161,7 @@ unix_to_efi(void)
|
|||
}
|
||||
printf("%s\n", efi);
|
||||
}
|
||||
free(dp);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Reference in a new issue