From cd9e93b2d10be1c3f996df94b911ad7b4f81b351 Mon Sep 17 00:00:00 2001 From: Slava Zanko Date: Fri, 29 Jan 2010 10:23:33 +0200 Subject: [PATCH] Ticket #1982: Segfault while opening gzip archive MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 1. touch /tmp/IzV-Útěk_do_bezpečí.gz 2. open mc 3. move cursor at /tmp/IzV-Útěk_do_bezpečí.gz 4. press F4 5. you will see an error message, press Dismiss 6. segfault Fix issue: length of command line string for pipeing now calculated automatically (via g_strdup_printf()) rathen than calculating via str_term_width1() function. Signed-off-by: Slava Zanko --- src/editor/edit.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/editor/edit.c b/src/editor/edit.c index 7f94c9f39..5fa2ca543 100644 --- a/src/editor/edit.c +++ b/src/editor/edit.c @@ -355,15 +355,13 @@ static int edit_find_filter (const char *filename) static char * edit_get_filter (const char *filename) { - int i, l; + int i; char *p, *quoted_name; i = edit_find_filter (filename); if (i < 0) return 0; quoted_name = name_quote (filename, 0); - l = str_term_width1 (quoted_name); - p = g_malloc0 (str_term_width1 (all_filters[i].read) + l + 2); - sprintf (p, all_filters[i].read, quoted_name); + p = g_strdup_printf(all_filters[i].read, quoted_name); g_free (quoted_name); return p; } @@ -371,15 +369,13 @@ edit_get_filter (const char *filename) char * edit_get_write_filter (const char *write_name, const char *filename) { - int i, l; + int i; char *p, *writename; i = edit_find_filter (filename); if (i < 0) return 0; writename = name_quote (write_name, 0); - l = str_term_width1 (writename); - p = g_malloc0 (str_term_width1 (all_filters[i].write) + l + 2); - sprintf (p, all_filters[i].write, writename); + p = g_strdup_printf(all_filters[i].write, writename); g_free (writename); return p; } -- 2.11.4.GIT