Print this page
10138 smatch fixes for usr/src/cmd/sgs

@@ -26,10 +26,14 @@
 /*
  *      Copyright (c) 1988 AT&T
  *        All Rights Reserved
  */
 
+/*
+ * Copyright (c) 2018, Joyent, Inc.
+ */
+
 #include <ar.h>
 #include <stdlib.h>
 #include <memory.h>
 #include <errno.h>
 #include <libelf.h>

@@ -154,10 +158,11 @@
         }
         if ((elf->ed_memlist == 0) || (ol->m_free == ol->m_end)) {
                 if ((l = (Memlist *)malloc(sizeof (Memlist) +
                     (sizeof (Memident) * MEMIDENTNO))) == 0) {
                         _elf_seterr(EMEM_ARMEM, errno);
+                        free(m);
                         return (0);
                 }
                 l->m_next = 0;
                 l->m_free = (Memident *)(l + 1);
                 l->m_end = (Memident *)((uintptr_t)l->m_free +