lightning
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Lightning] Lightning frees NULL pointers, and frees others it didn´t al


From: Ian Grant
Subject: [Lightning] Lightning frees NULL pointers, and frees others it didn´t allocate
Date: Sat, 26 Jul 2014 15:10:56 -0400

This one cost me eight hours of my time.

Here is a program which reproduces the problem, an example of the output, and a patch to lightning.c which adds some debug printfs which might help you find the problem. I suspect it´s in jit_dataset. I have tried to fix it but the code there is incomprehensible to me. It seems to test flags like _jitc->no_data, and on the basis of this, it makes assumptions about the values of pointer variables. But flags like this are just another possible source of inconsistency. It´s almost always better to test the pointers directly. There are also places in this function where it calls memcpy and copies to a NULL pointer.

There is another problem in that the manual indicates one can use separate _jit states concurrently, but this is not true because jit_new_state uses a global variable. The result is a space leak if it´s called twice. Another problem is that init_jit keeps a pointer to the program name, but the manual doesn´t state this. It should either warn about this in the manual, or better, use strncpy to keep a private copy of the string.

Ian

Attachment: testlightning.out
Description: Binary data

Attachment: lightning.patch
Description: Binary data

Attachment: testlightning.c
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]