[syslinux:elflink] module: Check return value of malloc()
syslinux-bot for Matt Fleming
matt.fleming at intel.com
Wed Jan 16 04:27:05 PST 2013
Commit-ID: 8deea7fccbf76bca2ec62057afc774540da1603e
Gitweb: http://www.syslinux.org/commit/8deea7fccbf76bca2ec62057afc774540da1603e
Author: Matt Fleming <matt.fleming at intel.com>
AuthorDate: Tue, 15 Jan 2013 14:57:45 +0000
Committer: Matt Fleming <matt.fleming at intel.com>
CommitDate: Wed, 16 Jan 2013 12:22:42 +0000
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 at intel.com>
---
com32/lib/sys/module/common.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index d72dd70..deb2bcc 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);
More information about the Syslinux-commits
mailing list