Moving forward to the software source code analysis. Updated more than 300 alloc-functions for GLib.
Here are new results (better and better):
https://gist.github.com/scriptum/7360333
Updated rules: https://github.com/scriptum/cppcheck-libs
-- Best regards, Pavel Roschin aka RPG
On 8 November 2013 06:22, Pavel Roschin roshin@scriptumplus.ru wrote:
Moving forward to the software source code analysis. Updated more than 300 alloc-functions for GLib.
Here are new results (better and better):
Nice, had a chance to check a couple while sitting in an airport.
symbols.c:1093 arrrrrggghh, keeping the buffer between function invocations!!! Why?? But its not a leak.
build.c:2416 build.c:2633 technical leak, doesn't happen in any real Geany, needs a menu of >100 items to trigger, replace the return by break to fix
build.c printfs are a debugging facility that is never used AFAICT and are always compiled out, but are safe anyway since the small unsigned ints have the same values as small signed ints.
utils.c:1844 yes, leaks. All the g_return_if_fail() calls in that function s/b replaced, the returns are not errors, there is no need to print a message if they occur, the tests are required, but g_return_if_fail() can be compiled out.
document.c:528 false pos, the doc allocated at 522 is added to the array at 525 not leaked, could be silenced by using a different GeanyDocument* temporary variable.
Your other assessments of false positives look right.
Cheers Lex
Updated rules: https://github.com/scriptum/cppcheck-libs
-- Best regards, Pavel Roschin aka RPG _______________________________________________ Devel mailing list Devel@lists.geany.org https://lists.geany.org/cgi-bin/mailman/listinfo/devel
Le 07/11/2013 20:22, Pavel Roschin a écrit :
[...]
https://gist.github.com/scriptum/7360333 [...] === LEAKS === ../geany/src/keyfile.c:665: error: Memory leak: tmp_array !NOT SURE. g_ptr_array_add called even for NULL???
Not sure either yet, looks kinda weird indeed.
../geany/src/symbols.c:1093: error: Memory leak: buffer
Yeah, but it's "only" a application-lifetime allocation.
../geany/src/build.c:2416: error: Memory leak: key ../geany/src/build.c:2633: error: Memory leak: key
Fixed.
../geany/src/utils.c:1062: error: Returning/dereferencing 'ioc' after it is deallocated / released !FALSE-POS (NOT SURE)
It is a false positive because g_io_add_watch() adds a reference and it can't be dropped before function exit in a single-threaded application at least.
../geany/src/utils.c:1844: error: Memory leak: tmp
And also str would have been leaked. I removed tmp altogether and made the function avoid that allocation, plus a few other improvements.
../geany/src/utils.c:739: portability: Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'. ../geany/src/utils.c:743: portability: Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'. ../geany/src/utils.c:1018: portability: Non reentrant function 'localtime' called. For threadsafe applications it is recommended to use the reentrant replacement function 'localtime_r'.
OK, but we're definitely not MT-safe :)
../geany/src/document.c:528: error: Memory leak: doc
False positive, the doc pointer is added to the documents array on L525, so it's fine we just get the same one on line 528.
../geany/src/document.c:1546: error: Memory leak: conv_file_contents !FALSE-POS - check pointer, not error?
Yeah we could check conv_file_contents instead of conv_error, although in practice it's probably identical.
== Some funny warnings === [...]
Fixed. Though, it's weird GCC didn't report those with -Wformat=2, weird.
Thanks again! Colomban