Re: [AD] [PATCH] Solaris Fixes and dev notes

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 6/5/05, Shawn Walker <binarycrusader@xxxxxxxxxx> wrote:
On 6/5/05, Elias Pschernig <elias@xxxxxxxxxxxxxxxxx > wrote:
On Sun, 2005-06-05 at 01:07 -0500, Shawn Walker wrote:

> 2) In several key cases XKeysymToString was being used to directly
> pass arguments to other routines, without checking the return value
> first. This is bad. XKeysymToString can return NULL as a value. I only
> fixed the places that were causing Allegro to segfault for me, not all
> of them. I noted that the Allegro code was already checking this in
> some places, but not in others. This should be addressed.
>

NULL is fine in these cases, it is passed as parameter to printf as a %s
argument, which allows NULL pointers (It prints "(null)").

In my case NULL values were being passed as arguments to AL_TRACE, which in turn was passing them to vsprintf, vsprintf assumes that the string values you pass it are valid strings. As a result, I get a segfault when it attempts to call strlen on the string data that was passed in. So the changes are needed. I would bet that the (null) behaviour you see is not something that you can rely on across all platforms.


I should note that I was running the example programs in LANG=en_US.UTF-8, NOT LANG=C, since that is my default locale. I had also forced them to all link against the debugging library which is why I might have encountered them.

--
Shawn Walker, Software and Systems Analyst
binarycrusader@xxxxxxxxxx - http://binarycrusader.blogspot.com/

Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/