After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 361428 - segmentation fault on win32 - g_vsnprintf if argument for %s is NULL
segmentation fault on win32 - g_vsnprintf if argument for %s is NULL
Status: RESOLVED NOTABUG
Product: glib
Classification: Platform
Component: win32
2.12.x
Other All
: Normal critical
: ---
Assigned To: gtk-win32 maintainers
gtk-win32 maintainers
Depends on:
Blocks:
 
 
Reported: 2006-10-11 13:22 UTC by Paulo Pizarro
Modified: 2006-10-11 14:55 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Paulo Pizarro 2006-10-11 13:22:58 UTC
Steps to reproduce:
1. g_vsnprintf(buffer, 512, "%s", NULL);
2. 
3. 


Stack trace:


Other information:
Comment 1 Paulo Pizarro 2006-10-11 13:28:44 UTC
verify line 546 on file glib-2.12.1/glib/gnulib/vasnprintf.c:

         tmp_length = strlen (a.arg[dp->arg_index].a.a_string);

error on strlen if "a.arg[dp->arg_index].a.a_string" is NULL.
Comment 2 Tor Lillqvist 2006-10-11 14:03:30 UTC
Not a bug. NULL is not a legal argument for %s. That some C libraries "helpfully" accept NULL anyway and print "(null)" or something similar is irrelevant.
Comment 3 Paulo Pizarro 2006-10-11 14:28:27 UTC
Ok, you're right, but take it as a suggestion :)

Several linux codes use it without problem (glibc prints "(null)" helpfully). But, when they are compiled for win32, they have problems.

I think that implementation would improve the cross-platform characteristcs of glib.

Thankx.
Comment 4 Tor Lillqvist 2006-10-11 14:41:37 UTC
But even if we fix the g_*print* functios, the behaviour of plain *printf functions directly from the (Microsoft) C library wouldn't change, which could be confusing. 

Oh well, I guess whether something should be done to thins issue depends on how we specify the g_*print* functions to behave. Now the documentation doesn't promise anything special. g_printf documentation just says "An implementation of the standard printf() function which supports positional parameters, as specified in the Single Unix Specification."

Remember that there are other platforms that Win32 and Linux; many proprietary UNIXes presumably have C libraries where printf crashes if you feed a NULL to %s. Not to mention embedded platforms.
Comment 5 Paulo Pizarro 2006-10-11 14:55:37 UTC
I agree.
From now on, I'll code taking care of it.
Thanks.