[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[libvirt] [PATCH] sanlock: Use STREQ_NULLABLE instead of STREQ on strings that may be null



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 |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c
index 13940f1..f2623a0 100644
--- a/src/locking/lock_driver_sanlock.c
+++ b/src/locking/lock_driver_sanlock.c
@@ -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;
-- 
1.7.3.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]