← Back to team overview

audio-recorder team mailing list archive

[Merge] lp:~osmoma/audio-recorder/trunk into lp:audio-recorder

 

moma has proposed merging lp:~osmoma/audio-recorder/trunk into lp:audio-recorder.

Commit message:
Fixing bug #1838710 in str_compare() function. Thanks to Chipschap and Roy.

Requested reviews:
  Audio-recorder (audio-recorder)

For more details, see:
https://code.launchpad.net/~osmoma/audio-recorder/trunk/+merge/372286
-- 
Your team Audio-recorder is requested to review the proposed merge of lp:~osmoma/audio-recorder/trunk into lp:audio-recorder.
=== modified file 'src/utility.c'
--- src/utility.c	2019-03-08 17:25:19 +0000
+++ src/utility.c	2019-09-04 18:07:33 +0000
@@ -1046,7 +1046,20 @@
 }
 
 gint str_compare(const gchar *s1, const gchar *s2, gboolean case_insensitive) {
-    if (*s1 == '\0' && *s2 == '\0') {
+
+    if (s1 == NULL && s2 == NULL) {
+        // Assume equals
+        return 0;
+    } else if (s1 == NULL) {
+        // s1 < s2
+        return -1;
+    } else if (s2 == NULL) {
+        // s1 > s2
+        return 1;
+    }
+
+    // Here both are valid (not NULL) strings
+    if (*s1 == '\0' && s2 == '\0') {
         // Equals
         return 0;   
     }