On 04/20/2012 02:31 PM, Matt Turner wrote:
> On Fri, Apr 20, 2012 at 5:18 PM, Chase Douglas
> <chase.doug...@canonical.com> wrote:
>> XauFileName() may allocate and return a static buffer. The only
>> way to ensure it is freed is to deallocate it when the program exits.
>>
>> Signed-off-by: Chase Douglas <chase.doug...@canonical.com>
>> ---
>>  AuFileName.c |   17 ++++++++++++++++-
>>  1 files changed, 16 insertions(+), 1 deletions(-)
>>
>> diff --git a/AuFileName.c b/AuFileName.c
>> index f384f75..bc7b177 100644
>> --- a/AuFileName.c
>> +++ b/AuFileName.c
>> @@ -31,13 +31,22 @@ in this Software without prior written authorization 
>> from The Open Group.
>>  #include <X11/Xos.h>
>>  #include <stdlib.h>
>>
>> +static char *buf = NULL;
>> +
>> +static void
>> +free_filename_buffer(void)
>> +{
>> +    free(buf);
>> +    buf = NULL;
>> +}
>> +
> 
> Strictly speaking, you don't need to set buf = NULL in either place.
> static variables are automatically initialized, and I can't imagine
> why the program should care what the value of buf is when it's
> exiting. :)

I like being pedantic when it comes to values that could crash your
program if you make an unrelated change, like removing the static keyword.

-- Chase
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to