diff options
author | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2013-04-23 21:21:00 -0300 |
---|---|---|
committer | Lucas De Marchi <lucas.de.marchi@gmail.com> | 2013-04-23 21:26:09 -0300 |
commit | 681bf89afd5ebe34de7651dccd6b2522d821d60e (patch) | |
tree | b43bffa77b3a03c1cd2c928e8c3cbcdb656f389e | |
parent | b9a7da391066768736a2f23a360a3995df4bc097 (diff) | |
download | kmod-681bf89afd5ebe34de7651dccd6b2522d821d60e.tar.gz |
libkmod-index: Return early if readroot failed
-rw-r--r-- | TODO | 2 | ||||
-rw-r--r-- | libkmod/libkmod-index.c | 10 |
2 files changed, 10 insertions, 2 deletions
@@ -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 d386f00..0f94059 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); } |