]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
sanlock: Use STREQ_NULLABLE instead of STREQ on strings that may be null
authorPeter Krempa <pkrempa@redhat.com>
Wed, 7 Mar 2012 14:04:33 +0000 (15:04 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Thu, 8 Mar 2012 10:49:32 +0000 (11:49 +0100)
The function sanlock_inquire can return NULL in the state string if the
message consists only of a header. The return value is arbitrary and
sent by the server. We should proceed carefully while touching such
pointers.

src/locking/lock_driver_sanlock.c

index 295e45d98beac6d0ae0376c4156ceccd7b5a2d07..d344d6ae4626bd028186cc4b12261071ad450088 100644 (file)
@@ -828,7 +828,7 @@ static int virLockManagerSanlockRelease(virLockManagerPtr lock,
             return -1;
         }
 
-        if (STREQ(*state, ""))
+        if (STREQ_NULLABLE(*state, ""))
             VIR_FREE(*state);
     }
 
@@ -871,7 +871,7 @@ static int virLockManagerSanlockInquire(virLockManagerPtr lock,
         return -1;
     }
 
-    if (STREQ(*state, ""))
+    if (STREQ_NULLABLE(*state, ""))
         VIR_FREE(*state);
 
     return 0;