[Gnucash-changes] QOF/CashUtil Sync: Engine

Christian Stimming stimming at tuhh.de
Wed Aug 17 09:00:04 EDT 2005


By the way, these *_sprintf() functions have an additional issue:

Derek Atkins schrieb:
>>diff -Lsrc/engine/FreqSpec.c -Lsrc/engine/FreqSpec.c -u -r1.28.4.8 -r1.28.4.9
>>--- src/engine/FreqSpec.c
>>+++ src/engine/FreqSpec.c
>>@@ -74,7 +74,6 @@
>> \********************************************************************/
> 
> [snip]
> 
>>   {
>>     /* This is displayed instead of the number of the day of month. */
>>-    g_string_sprintf(str, _( "last day"));
>>+    g_string_sprintf(str, (char*)_( "last day"));
>>   }

The second argument of these sprintf() calls is supposed to be the 
*format* string, *not* the string content itself. If it contains a '%' 
character, then it will accidentally be interpreted as a conversion 
specification and the call will look for more arguments; since there are 
no more arguments, the program will crash. Even worse, since this is a 
translated string, any of the translations might also contain the '%' 
character, so the argument '"last day" does not contain the % character' 
is not an excuse here.

In short: If it is a simple assignment, it should be changed to the 
appropriate function
   g_string_assign(str, _("bla bla"));
or otherwise an appropriate conversion specifier should be used:
   g_string_sprintf(str, "%s", _("bla bla"));

I don't know who is to blame for this one -- probably not Neil this time 
;-) . But that's a general issue with the printf() family of functions.

Regards,

Christian


More information about the gnucash-devel mailing list