Handle memory allocation failures in include().
PR: i386/85652 Submitted by: Ben Thomas <bthomas at virtualiron.com> MFC after: 3 days
This commit is contained in:
parent
05f2685017
commit
94fe6c80c7
@ -246,6 +246,17 @@ include(const char *filename)
|
|||||||
if (*cp == '\0')
|
if (*cp == '\0')
|
||||||
continue; /* ignore empty line, save memory */
|
continue; /* ignore empty line, save memory */
|
||||||
sp = malloc(sizeof(struct includeline) + strlen(cp) + 1);
|
sp = malloc(sizeof(struct includeline) + strlen(cp) + 1);
|
||||||
|
/* On malloc failure (it happens!), free as much as possible and exit */
|
||||||
|
if (sp == NULL) {
|
||||||
|
while (script != NULL) {
|
||||||
|
se = script;
|
||||||
|
script = script->next;
|
||||||
|
free(se);
|
||||||
|
}
|
||||||
|
sprintf(command_errbuf, "file '%s' line %d: memory allocation "
|
||||||
|
"failure - aborting\n", filename, line);
|
||||||
|
return (CMD_ERROR);
|
||||||
|
}
|
||||||
strcpy(sp->text, cp);
|
strcpy(sp->text, cp);
|
||||||
#ifndef BOOT_FORTH
|
#ifndef BOOT_FORTH
|
||||||
sp->flags = flags;
|
sp->flags = flags;
|
||||||
|
@ -204,7 +204,7 @@ efipart_readwrite(EFI_BLOCK_IO *blkio, int rw, daddr_t blk, daddr_t nblks,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (EFI_ERROR(status))
|
if (EFI_ERROR(status))
|
||||||
printf("%s: rw=%d, status=%lu\n", __func__, rw, status);
|
printf("%s: rw=%d, status=%u\n", __func__, rw, status);
|
||||||
return (efi_status_to_errno(status));
|
return (efi_status_to_errno(status));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user