From db7599e9e5b53c92235ef8a00b77ba410f994481 Mon Sep 17 00:00:00 2001 From: Toomas Soome Date: Sun, 7 Apr 2019 11:50:41 +0000 Subject: [PATCH] loader: file_addmodule should check for memory allocation strdup() can return NULL. MFC after: 1w --- stand/common/module.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/stand/common/module.c b/stand/common/module.c index 1462e997327..1baad1342d2 100644 --- a/stand/common/module.c +++ b/stand/common/module.c @@ -930,6 +930,10 @@ file_addmodule(struct preloaded_file *fp, char *modname, int version, if (mp == NULL) return (ENOMEM); mp->m_name = strdup(modname); + if (mp->m_name == NULL) { + free(mp); + return (ENOMEM); + } mp->m_version = version; mp->m_fp = fp; mp->m_next = fp->f_modules;