]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod-index: Return early if readroot failed
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 24 Apr 2013 00:21:00 +0000 (21:21 -0300)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Wed, 24 Apr 2013 00:26:09 +0000 (21:26 -0300)
TODO
libkmod/libkmod-index.c

diff --git a/TODO b/TODO
index b2dc1cf9691aed2340baa5014ab2e428b0894d0c..ccfc0c031640afde9bcc5efd958ff2a24509485a 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,6 +1,8 @@
 Features:
 =========
 
+* Protect index against OOM
+
 * Implement actions in kmod tool like 'insert', 'remove', 'info', etc
 
 * testsuite:
index d386f00b01add08e2ecc93bb912edd843a3cd051..0f9405988d82c9894de799fd23f0adf8e3550b08 100644 (file)
@@ -432,9 +432,12 @@ void index_dump(struct index_file *in, int fd, const char *prefix)
        struct index_node_f *root;
        struct buffer buf;
 
+       root = index_readroot(in);
+       if (root == NULL)
+               return;
+
        buf_init(&buf);
        buf_pushchars(&buf, prefix);
-       root = index_readroot(in);
        index_dump_node(root, &buf, fd);
        buf_release(&buf);
 }
@@ -902,9 +905,12 @@ void index_mm_dump(struct index_mm *idx, int fd, const char *prefix)
        struct index_mm_node *root;
        struct buffer buf;
 
+       root = index_mm_readroot(idx);
+       if (root == NULL)
+               return;
+
        buf_init(&buf);
        buf_pushchars(&buf, prefix);
-       root = index_mm_readroot(idx);
        index_mm_dump_node(root, &buf, fd);
        buf_release(&buf);
 }