]> git.notmuchmail.org Git - notmuch/blobdiff - lib/index.cc
lib/index: Fix memory leak for email addresses without names.
[notmuch] / lib / index.cc
index 747a4e63334c1aa3c5602134f39ecfb1ab8d3978..125fa6c94f2b6612f6aac3e36dfe518753eaddaf 100644 (file)
@@ -31,39 +31,27 @@ _index_address_mailbox (notmuch_message_t *message,
 {
     InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
     const char *name, *addr;
 {
     InternetAddressMailbox *mailbox = INTERNET_ADDRESS_MAILBOX (address);
     const char *name, *addr;
-    char *contact;
-    int own_name = 0;
+    void *local = talloc_new (NULL);
 
     name = internet_address_get_name (address);
     addr = internet_address_mailbox_get_addr (mailbox);
 
 
     name = internet_address_get_name (address);
     addr = internet_address_mailbox_get_addr (mailbox);
 
-    if (addr) {
-       if (name) {
-           contact = talloc_asprintf (message, "\"%s\" <%s>",
-                                      name, addr);
-           _notmuch_message_add_term (message, "contact", contact);
-           talloc_free (contact);
-       } else {
-           _notmuch_message_add_term (message, "contact", addr);
-       }
-    }
-
     /* In the absence of a name, we'll strip the part before the @
      * from the address. */
     if (! name) {
        const char *at;
 
        at = strchr (addr, '@');
     /* In the absence of a name, we'll strip the part before the @
      * from the address. */
     if (! name) {
        const char *at;
 
        at = strchr (addr, '@');
-       if (at) {
-           name = strndup (addr, at - addr);
-           own_name = 1;
-       }
+       if (at)
+           name = talloc_strndup (local, addr, at - addr);
     }
 
     if (name)
        _notmuch_message_gen_terms (message, prefix_name, name);
     if (addr)
        _notmuch_message_gen_terms (message, prefix_name, addr);
     }
 
     if (name)
        _notmuch_message_gen_terms (message, prefix_name, name);
     if (addr)
        _notmuch_message_gen_terms (message, prefix_name, addr);
+
+    talloc_free (local);
 }
 
 static void
 }
 
 static void
@@ -210,7 +198,7 @@ _index_mime_part (notmuch_message_t *message,
                if (i == 1)
                    continue;
                if (i > 1)
                if (i == 1)
                    continue;
                if (i > 1)
-                   fprintf (stderr, "Warning: Unexpected extra parts of mutlipart/signed. Indexing anyway.\n");
+                   fprintf (stderr, "Warning: Unexpected extra parts of multipart/signed. Indexing anyway.\n");
            }
            _index_mime_part (message,
                              g_mime_multipart_get_part (multipart, i));
            }
            _index_mime_part (message,
                              g_mime_multipart_get_part (multipart, i));