]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
parser: Fix crash when maps structure is NULL
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 6 Jul 2010 07:23:54 +0000 (10:23 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Tue, 6 Jul 2010 07:23:54 +0000 (10:23 +0300)
The maps structure can be NULL when scanning kernel processes.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
parse.c

diff --git a/parse.c b/parse.c
index 7ae61a19f01627bd90dcaea8eff6e5227e5f2cee..c93e3990b310a5d3fad6118d2a5bc1ab1c454671 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -133,6 +133,9 @@ static int parse_pageframe(FILE *file, struct pageframe *pf_tree,
        unsigned long long pf;
        int ret, error;
 
+       if (maps == NULL)
+               return 0;
+
        /* Go through the list of allocated memory areas */
        list_for_each_entry(map, &maps->list, list) {
                start = map->start >> (PAGE_SHIFT - 3);
@@ -250,6 +253,9 @@ void read_pageframe(int pid, struct pageframe *pageframe,
                process->name[ret - 1] = 0;
        fclose(file);
 
+       if (maps == NULL)
+               return;
+
        list_for_each_entry(maps, &process->maps->list, list) {
                process->pages_present += maps->pages_present;
                process->pages_swapped += maps->pages_swapped;