libmultipath: fix segfault when vector is null
authorMike Christie <michaelc@cs.wisc.edu>
Tue, 8 Jan 2013 19:36:34 +0000 (13:36 -0600)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 8 Jan 2013 22:09:44 +0000 (23:09 +0100)
While performing tests that caused paths to get added
and deleted, we hit a segfault. We traced it to the
vector struct being NULL. This patch fixes the problem
by checking for a NULL vector before accessing it.

Signed-off-by: Mike Christie <michaelc@cs.wisc.edu>
libmultipath/vector.c

index 652f118..0564224 100644 (file)
@@ -94,6 +94,9 @@ find_slot(vector v, void * addr)
 {
        int i;
 
+       if (!v)
+               return -1;
+
        for (i = 0; i < (v->allocated / VECTOR_DEFAULT_SIZE); i++)
                if (v->slot[i] == addr)
                        return i;