Check for invalid combination of prefix and comma separation before
authorVeerapuram Varadhan <vvaradan@src.gnome.org>
Fri, 16 Dec 2005 16:34:41 +0000 (16:34 +0000)
committerVeerapuram Varadhan <vvaradan@src.gnome.org>
Fri, 16 Dec 2005 16:34:41 +0000 (16:34 +0000)
* libebook/e-name-western.c (e_name_western_reorder_asshole): Check for invalid combination of prefix and comma separation before reordering the name.
** Fixes #317411

addressbook/ChangeLog
addressbook/libebook/e-name-western.c

index 2a2bd34..e0a5362 100644 (file)
@@ -1,3 +1,10 @@
+2005-12-16  Veerapuram Varadhan <vvaradhan@novell.com>
+
+       * libebook/e-name-western.c: (e_name_western_reorder_asshole):
+       Check for invalid combination of prefix and comma separation
+       before reordering the name.
+       ** Fixes #317411
+       
 2005-12-09  Tor Lillqvist  <tml@novell.com>
 
        * libedata-book/e-book-backend-summary.c: Use gstdio wrappers.
index 0cb5491..6b91b6b 100644 (file)
@@ -659,7 +659,24 @@ e_name_western_reorder_asshole (ENameWestern *name, ENameWesternIdxs *idxs)
 
        while (g_unichar_isspace (g_utf8_get_char (p)) && *p != '\0')
                p = g_utf8_next_char (p);
-
+       
+       /* 
+          Consider this case, "Br.Gate,Br. Gate,W". I know this is a damn
+          random name, but, I got this from the bug report of 317411.
+          
+          comma = ",Br.Gate,W"
+          prefix = "Br.Gate,Br."
+          p = " Gate,W"
+          comma - p < 0 and hence the crash.
+
+          Actually, we don't have to put lot of intelligence in reordering such
+          screwedup names, just return.
+       */
+       if (comma - p + 1 < 1) {
+               g_free (prefix);
+               return;
+       }
+       
        last = g_malloc0 (comma - p + 1);
        strncpy (last, p, comma - p);
 
@@ -941,7 +958,7 @@ e_name_western_parse (const char *full_name)
        idxs->nick_idx   = -1;
        idxs->last_idx   = -1;
        idxs->suffix_idx = -1;
-       
+
        /*
         * An extremely simple algorithm.
         *