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;
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to