Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Apr 2019 12:10:19 +0000 (UTC)
From:      Toomas Soome <tsoome@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r346001 - head/stand/common
Message-ID:  <201904071210.x37CAJHE095539@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: tsoome
Date: Sun Apr  7 12:10:19 2019
New Revision: 346001
URL: https://svnweb.freebsd.org/changeset/base/346001

Log:
  loader: file_addmetadata() should check for memory allocation
  
  malloc() can return NULL.
  
  MFC after:	1w

Modified:
  head/stand/common/module.c

Modified: head/stand/common/module.c
==============================================================================
--- head/stand/common/module.c	Sun Apr  7 11:55:11 2019	(r346000)
+++ head/stand/common/module.c	Sun Apr  7 12:10:19 2019	(r346001)
@@ -677,10 +677,12 @@ file_addmetadata(struct preloaded_file *fp, int type, 
 	struct file_metadata	*md;
 
 	md = malloc(sizeof(struct file_metadata) - sizeof(md->md_data) + size);
-	md->md_size = size;
-	md->md_type = type;
-	bcopy(p, md->md_data, size);
-	md->md_next = fp->f_metadata;
+	if (md != NULL) {
+		md->md_size = size;
+		md->md_type = type;
+		bcopy(p, md->md_data, size);
+		md->md_next = fp->f_metadata;
+	}
 	fp->f_metadata = md;
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201904071210.x37CAJHE095539>