From: Lucas De Marchi Date: Wed, 24 Apr 2013 00:21:00 +0000 (-0300) Subject: libkmod-index: Return early if readroot failed X-Git-Tag: v14~13 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=681bf89afd5ebe34de7651dccd6b2522d821d60e;p=thirdparty%2Fkmod.git libkmod-index: Return early if readroot failed --- diff --git a/TODO b/TODO index b2dc1cf9..ccfc0c03 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,8 @@ Features: ========= +* Protect index against OOM + * Implement actions in kmod tool like 'insert', 'remove', 'info', etc * testsuite: diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index d386f00b..0f940598 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -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); }