[balsa] address: Avoid a scan-build false positive



commit b9d58d6fe81c31a2a65f521e5c9a3c6ff1fcbe4a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Mon Feb 18 17:52:42 2019 -0500

    address: Avoid a scan-build false positive
    
    * libbalsa/address.c (vcard_strsplit): eliminate one decrement,
      and add an assertion to avoid a scan-build false positive

 ChangeLog          | 5 +++++
 libbalsa/address.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b10f53c34..0ff0689cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2019-02-18  Peter Bloomfield  <pbloomfield bellsouth net>
+
+       * libbalsa/address.c (vcard_strsplit): eliminate one decrement,
+       and add an assertion to avoid a scan-build false positive
+
 2019-02-18  Peter Bloomfield  <pbloomfield bellsouth net>
 
        * libbalsa/mailbox.c (libbalsa_mailbox_view_new): initialize a
diff --git a/libbalsa/address.c b/libbalsa/address.c
index c0e58f878..20e35b639 100644
--- a/libbalsa/address.c
+++ b/libbalsa/address.c
@@ -297,7 +297,7 @@ vcard_strsplit(const gchar * string)
 
     str_array = g_new(gchar*, n + 1);
 
-    str_array[n--] = NULL;
+    str_array[n] = NULL;
     for (slist = string_list; slist; slist = slist->next) {
        gchar * str = (gchar *) slist->data;
        gchar * p;
@@ -310,8 +310,9 @@ vcard_strsplit(const gchar * string)
            g_free(str);
            str = newstr;
        }
-       str_array[n--] = str;
+       str_array[--n] = str;
     }
+    g_assert(n == 0);
 
     g_slist_free(string_list);
 


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