svn commit: r219054 - stable/7/sys/boot/common
Bruce Cran
brucec at FreeBSD.org
Sat Feb 26 12:07:17 UTC 2011
Author: brucec
Date: Sat Feb 26 12:07:16 2011
New Revision: 219054
URL: http://svn.freebsd.org/changeset/base/219054
Log:
MFC r218974:
Handle memory allocation failures in include().
PR: i386/85652
Submitted by: Ben Thomas <bthomas at virtualiron.com>
Modified:
stable/7/sys/boot/common/interp.c
Directory Properties:
stable/7/sys/ (props changed)
stable/7/sys/cddl/contrib/opensolaris/ (props changed)
stable/7/sys/contrib/dev/acpica/ (props changed)
stable/7/sys/contrib/pf/ (props changed)
Modified: stable/7/sys/boot/common/interp.c
==============================================================================
--- stable/7/sys/boot/common/interp.c Sat Feb 26 12:04:34 2011 (r219053)
+++ stable/7/sys/boot/common/interp.c Sat Feb 26 12:07:16 2011 (r219054)
@@ -246,6 +246,17 @@ include(const char *filename)
if (*cp == '\0')
continue; /* ignore empty line, save memory */
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);
#ifndef BOOT_FORTH
sp->flags = flags;
More information about the svn-src-stable-7
mailing list