From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by arlo.cworth.org (Postfix) with ESMTP id EB7836DE16EC for ; Sat, 18 Mar 2017 10:51:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at cworth.org X-Spam-Flag: NO X-Spam-Score: -0.005 X-Spam-Level: X-Spam-Status: No, score=-0.005 tagged_above=-999 required=5 tests=[AWL=0.006, SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from arlo.cworth.org ([127.0.0.1]) by localhost (arlo.cworth.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id pAMFeuBpcII1 for ; Sat, 18 Mar 2017 10:51:03 -0700 (PDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by arlo.cworth.org (Postfix) with ESMTPS id F07926DE16EE for ; Sat, 18 Mar 2017 10:50:54 -0700 (PDT) Received: from remotemail by fethera.tethera.net with local (Exim 4.84_2) (envelope-from ) id 1cpIUW-0001Pq-0z; Sat, 18 Mar 2017 13:50:12 -0400 Received: (nullmailer pid 15965 invoked by uid 1000); Sat, 18 Mar 2017 17:50:46 -0000 From: David Bremner To: notmuch@notmuchmail.org Subject: [PATCH 5/6] cli/show: fix usage of g_mime_content_type_to_string Date: Sat, 18 Mar 2017 14:50:37 -0300 Message-Id: <20170318175038.15887-6-david@tethera.net> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170318175038.15887-1-david@tethera.net> References: <20170318175038.15887-1-david@tethera.net> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 18 Mar 2017 17:51:04 -0000 It returns an "allocated string", which needs to be freed. --- notmuch-show.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/notmuch-show.c b/notmuch-show.c index b0afc29e..43ee9021 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -438,6 +438,7 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, notmuch_message_get_flag (message, NOTMUCH_MESSAGE_FLAG_EXCLUDED) ? 1 : 0, notmuch_message_get_filename (message)); } else { + char *content_string; const char *disposition = _get_disposition (meta); const char *cid = g_mime_object_get_content_id (meta); const char *filename = leaf ? @@ -454,7 +455,10 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, printf (", Filename: %s", filename); if (cid) printf (", Content-id: %s", cid); - printf (", Content-type: %s\n", g_mime_content_type_to_string (content_type)); + + content_string = g_mime_content_type_to_string (content_type); + printf (", Content-type: %s\n", content_string); + g_free (content_string); } if (GMIME_IS_MESSAGE (node->part)) { @@ -495,8 +499,9 @@ format_part_text (const void *ctx, sprinter_t *sp, mime_node_t *node, show_text_part_content (node->part, stream_stdout, 0); g_object_unref(stream_stdout); } else { - printf ("Non-text part: %s\n", - g_mime_content_type_to_string (content_type)); + char *content_string = g_mime_content_type_to_string (content_type); + printf ("Non-text part: %s\n", content_string); + g_free (content_string); } } @@ -564,6 +569,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, GMimeObject *meta = node->envelope_part ? GMIME_OBJECT (node->envelope_part) : node->part; GMimeContentType *content_type = g_mime_object_get_content_type (meta); + char *content_string; const char *disposition = _get_disposition (meta); const char *cid = g_mime_object_get_content_id (meta); const char *filename = GMIME_IS_PART (node->part) ? @@ -592,7 +598,9 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, } sp->map_key (sp, "content-type"); - sp->string (sp, g_mime_content_type_to_string (content_type)); + content_string = g_mime_content_type_to_string (content_type); + sp->string (sp, content_string); + g_free (content_string); if (disposition) { sp->map_key (sp, "content-disposition"); -- 2.11.0