Fix memory leak
authorJonathan Dieter <jdieter@gmail.com>
Fri, 14 Sep 2018 12:21:58 +0000 (13:21 +0100)
committerJonathan Dieter <jdieter@gmail.com>
Fri, 14 Sep 2018 12:21:58 +0000 (13:21 +0100)
(Coverity ID: 310910)

Signed-off-by: Jonathan Dieter <jdieter@gmail.com>
src/lib/index/index_read.c

index 136c1bd4eb193195d1d2f17fabc8b54564ec978b..2754750aedd01be76ebcfff9e8c84835f68d05d6 100644 (file)
@@ -24,6 +24,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include <assert.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <stdbool.h>
@@ -67,19 +68,12 @@ bool index_read(zckCtx *zck, char *data, size_t size, size_t max_length) {
         }
 
         zckChunk *new = zmalloc(sizeof(zckChunk));
-        if(!new) {
-            set_fatal_error(zck, "Unable to allocate %lu bytes",
-                            sizeof(zckChunk));
-            return false;
-        }
+        assert(new);
 
         /* Read index entry digest */
         new->digest = zmalloc(zck->index.digest_size);
-        if(!new->digest) {
-            set_fatal_error(zck, "Unable to allocate %lu bytes",
-                                 zck->index.digest_size);
-            return false;
-        }
+        assert(new->digest);
+
         memcpy(new->digest, data+length, zck->index.digest_size);
         new->digest_size = zck->index.digest_size;
         length += zck->index.digest_size;