diff options
author | Matt Fleming <matt.fleming@intel.com> | 2013-01-15 14:57:45 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2013-01-16 12:22:42 +0000 |
commit | 8deea7fccbf76bca2ec62057afc774540da1603e (patch) | |
tree | 8620c8414b01713e762584706191eb66df3492fe | |
parent | ab06ca87afc01c1146a878989524eef03f331d7e (diff) | |
download | syslinux-8deea7fccbf76bca2ec62057afc774540da1603e.tar.gz syslinux-8deea7fccbf76bca2ec62057afc774540da1603e.tar.xz syslinux-8deea7fccbf76bca2ec62057afc774540da1603e.zip |
module: Check return value of malloc()
And return NULL after printing an appropriate error message if the
call failed.
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | com32/lib/sys/module/common.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c index d72dd702..deb2bcc8 100644 --- a/com32/lib/sys/module/common.c +++ b/com32/lib/sys/module/common.c @@ -185,6 +185,11 @@ void modules_term(void) { struct elf_module *module_alloc(const char *name) { struct elf_module *result = malloc(sizeof(struct elf_module)); + if (!result) { + dprintf("module: Failed to alloc elf_module\n"); + return NULL; + } + memset(result, 0, sizeof(struct elf_module)); INIT_LIST_HEAD(&result->list); |