From 2ae6f54200bad1f3609ba25b61917c56066e4dc3 Mon Sep 17 00:00:00 2001 From: Rob Norris Date: Sun, 20 Jul 2014 10:27:24 +0100 Subject: [PATCH] Prevention of crashing in mapcache when tmp variable is NULL. I haven't been able to trace why/when tmp becomes NULL, but at least one user has encountered this condition. Thus add protection against deferencing a NULL pointer. --- src/mapcache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mapcache.c b/src/mapcache.c index 5417ae1a..16422abe 100644 --- a/src/mapcache.c +++ b/src/mapcache.c @@ -182,6 +182,7 @@ void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint16 type, /* TODO: check logic here */ do { tmp = loop->next; + if ( tmp ) { if ( strncmp(tmp->key, key, len) == 0 ) { cache_remove(tmp->key); @@ -198,7 +199,8 @@ void a_mapcache_remove_all_shrinkfactors ( gint x, gint y, gint z, guint16 type, } else loop = tmp; - + } else + loop = NULL; } while ( loop && (loop != queue_tail || tmp == NULL) ); /* loop thru list, looking for the one, compare first whatever chars */ -- 2.39.5