printf: fix handling of old printf extension specifiers for ABI compatibility

Fixes abort when the old specifiers are used. Fix up the conversion
specifier, it would get overwritten with 'c' below to the extension
format char, which then later is unhandled, leading to the abort.
Also fix up and enable unit test for this.

https://bugzilla.gnome.org/process_bug.cgi
This commit is contained in:
Tim-Philipp Müller 2013-04-18 00:44:32 +01:00
parent c398c842f5
commit e8a9f7acdf
2 changed files with 14 additions and 6 deletions

View file

@ -392,7 +392,7 @@ printf_parse (const char *format, char_directives * d, arguments * a)
type = TYPE_POINTER_EXT;
dp->flags |= FLAG_PTR_EXT;
dp->ptr_ext_char = 'A';
dp->conversion = 'p';
c = 'p';
break;
case 'p':
/* Note: cp points already to the char after the 'p' now */
@ -413,7 +413,7 @@ printf_parse (const char *format, char_directives * d, arguments * a)
type = TYPE_POINTER_EXT;
dp->flags |= FLAG_PTR_EXT;
dp->ptr_ext_char = 'B';
dp->conversion = 'p';
c = 'p';
break;
case 'n':
#ifdef HAVE_LONG_LONG

View file

@ -290,10 +290,18 @@ GST_START_TEST (info_old_printf_extensions)
fail_unless_equals_int (g_list_length (messages), 1);
str = (gchar *) messages->data;
fail_unless (str != NULL);
GST_INFO ("str = '%s'", str);
fail_unless (strstr (str, "time") != NULL);
fail_unless (strstr (str, "start=0:00:00.000000000") != NULL);
fail_unless (strstr (str, "stop=99:99:99.999999999") != NULL);
fail_unless (strstr (str, "applied_rate=1.000000") != NULL);
fail_unless (strstr (str, " caps are ") != NULL);
fail_unless (strstr (str, "foo/bar") != NULL);
fail_unless (strstr (str, "width=(int)4096") != NULL);
fail_unless (strstr (str, "framerate=(fraction)50/1") != NULL);
fail_unless (strstr (str, "time") != NULL);
fail_unless (strstr (str, "ARGB") != NULL);
/* clean up */
@ -323,7 +331,7 @@ gst_info_suite (void)
tcase_add_test (tc_chain, info_log_handler);
tcase_add_test (tc_chain, info_dump_mem);
tcase_add_test (tc_chain, info_fixme);
tcase_skip_broken_test (tc_chain, info_old_printf_extensions);
tcase_add_test (tc_chain, info_old_printf_extensions);
#endif
return s;