elementary/index - fixed null string segfault case
authorhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 12 Mar 2012 11:10:57 +0000 (11:10 +0000)
committerhermet <hermet@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33>
Mon, 12 Mar 2012 11:10:57 +0000 (11:10 +0000)
git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/elementary@69247 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33

src/lib/elm_index.c

index 8c6967f..cf5893c 100644 (file)
@@ -436,23 +436,26 @@ _sel_eval(Evas_Object *obj, Evas_Coord evx, Evas_Coord evy)
         if (it_closest)
           {
              it = it_closest;
-             if (!last)
+             if (!last && it->letter)
                last = strdup(it->letter);
              else
                {
-                  if (!label) label = strdup(last);
+                  if (!label && last) label = strdup(last);
                   else
                     {
-                       label = realloc(label, strlen(label) + strlen(last) + 1);
-                       if (!label) return;
-                       strcat(label, last);
+                       if (label && last)
+                         {
+                            label = realloc(label, strlen(label) +
+                                            strlen(last) + 1);
+                            if (!label) return;
+                            strcat(label, last);
+                         }
                     }
                   free(last);
-                  last = strdup(it->letter);
+                  if (it->letter) last = strdup(it->letter);
                }
           }
      }
-
    if (!label) label = strdup("");
    if (!last) last = strdup("");
    edje_object_part_text_set(wd->base, "elm.text.body", label);