Skip to content

Instantly share code, notes, and snippets.

View scriptum's full-sized avatar

Pavel Roschin scriptum

View GitHub Profile
@scriptum
scriptum / config.h
Created October 24, 2013 20:03
config.h (geany-plugins)
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* always defined to indicate that i18n is enabled */
#define ENABLE_NLS 1
/* Location of Python library to dlopen() */
/* #undef GEANYPY_PYTHON_LIBRARY */
/* The domain to use with gettext */
@scriptum
scriptum / gtk.cfg
Last active December 27, 2015 06:29
cppcheck config for glib
<?xml version="1.0"?>
<def>
<memory>
<alloc>g_variant_builder_new</alloc>
<use>g_variant_builder_ref</use>
<dealloc>g_variant_builder_unref</dealloc>
</memory>
<memory>
<alloc>g_variant_new</alloc>
<alloc>g_variant_new_va</alloc>
@scriptum
scriptum / geany-plugins-cppcheck-result
Last active December 27, 2015 06:29
Geany plugins cppcheck result
$ ./cppcheck ../geany-plugins --library=geany `pkg-config --cflags glib-2.0` --max-configs=1 -j32 -q --template=gcc
../geany-plugins/debugger/src/tpage.c:117: error: Allocation with g_path_get_dirname, strcpy doesn't release it.
../geany-plugins/debugger/src/dbm_gdb.c:762: error: Memory leak: unescaped
../geany-plugins/geanylatex/src/templates.c:84: error: Memory leak: tmp_basedir
../geany-plugins/geanylatex/src/geanylatex.c:974: error: Mismatching allocation and deallocation: template_string
../geany-plugins/geanyprj/src/utils.c:72: error: Memory leak: v
../geany-plugins/geanysendmail/src/geanysendmail.c:114: error: Memory leak: cmd_str
../geany-plugins/geanysendmail/src/geanysendmail.c:173: error: Memory leak: config
../geany-plugins/geniuspaste/src/geniuspaste.c:223: error: Memory leak: f_title
../geany-plugins/devhelp/devhelp/ige-conf-mac.c:326: error: Memory leak: data
@scriptum
scriptum / geany.xml
Last active December 27, 2015 08:09
Geany/GTK config for cppcheck
<?xml version="1.0"?>
<def>
<memory>
<alloc>g_array_new</alloc>
<alloc>g_array_sized_new</alloc>
<use>g_array_ref</use>
<dealloc>g_array_free</dealloc>
<dealloc>g_array_unref</dealloc>
</memory>
<memory>
@scriptum
scriptum / gegl-cppcheck
Created November 3, 2013 20:57
Cppcheck 1.62 with GTK extensions
$ ./cppcheck ../gegl --library=geany `pkg-config --cflags glib-2.0` --max-configs=1 -j32 -q --template=gcc
../gegl/examples/gegl-convert.c:35: error: Memory pointed to by 'buffer' is freed twice.
../gegl/gegl/buffer/gegl-buffer-save.c:213: error: Memory leak: info
../gegl/gegl/buffer/gegl-buffer-load.c:266: error: Memory leak: info
../gegl/gegl/graph/gegl-node.c:1928: error: Returning/dereferencing 'child' after it is deallocated / released
../gegl/gegl/graph/gegl-node.c:1992: error: Returning/dereferencing 'node' after it is deallocated / released
../gegl/gegl/graph/gegl-node.c:2066: error: Returning/dereferencing 'nop' after it is deallocated / released
../gegl/gegl/graph/gegl-node.c:1776: error: Memory leak: proxy_name
../gegl/gegl/graph/gegl-node.c:314: error: Uninitialized variable: null
../gegl/gegl/property-types/gegl-paramspecs.c:275: error: Returning/dereferencing 'sspec' after it is deallocated / released
@scriptum
scriptum / system_safe.c
Last active December 27, 2015 13:59
Safe version of `system` call. It doesn't look at PATH and doesn't run command through shell.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#define __USE_GNU
#include <unistd.h>
#include <sys/wait.h>
/*
* like a system() call but much safier and don't use bash which can
* lead you to unnecessary code execution.
@scriptum
scriptum / geany-cppcheck-result
Last active December 27, 2015 17:09
Geany code analysis by cppchech with my glib config
=== COMMANDLINE ===
$ ./cppcheck --max-configs=1 -q -j16 --library=gtk --enable=performance,portability,information,warning --template=gcc --inconclusive --std=posix ../geany/src/ `pkg-config --cflags glib-2.0`
=== LEAKS ===
../geany/src/keyfile.c:665: error: Memory leak: tmp_array !NOT SURE. g_ptr_array_add called even for NULL???
../geany/src/symbols.c:1093: error: Memory leak: buffer
../geany/src/build.c:830: error: Mismatching allocation and deallocation: argv !FALSE-POS
../geany/src/build.c:856: error: Mismatching allocation and deallocation: argv !FALSE-POS
../geany/src/build.c:2416: error: Memory leak: key
../geany/src/build.c:2633: error: Memory leak: key
@scriptum
scriptum / cppcheck-deadbeef
Last active December 27, 2015 18:50
Cppcheck analysis of deadbeef 0.5.6
$ cppcheck -q -j16 --library=gtk --template=gcc --std=posix .
dsppreset.c:59: error: Width 100 given in format string (no. 1) is larger than destination buffer 'temp[100]', use %99s to prevent overflowing it.
intl/vasnprintf.c:4717: error: Uninitialized variable: pad_ourselves
intl/vasnprintf.c:4755: error: Uninitialized variable: pad_ourselves
md5/md5.c:207: error: Uninitialized variable: X
md5/md5.c:208: error: Uninitialized variable: X
md5/md5.c:209: error: Uninitialized variable: X
md5/md5.c:210: error: Uninitialized variable: X
md5/md5.c:211: error: Uninitialized variable: X
md5/md5.c:212: error: Uninitialized variable: X
@scriptum
scriptum / cppcheck-gimp
Created November 8, 2013 18:25
Cppcheck analysis of GIMP
$ cppcheck --max-configs=1 -q -j16 --library=gtk --template=gcc --std=posix `pkg-config --cflags glib-2.0` .
app/config/gimpconfig-dump.c:472: error: Memory leak: blurb
app/actions/view-actions.c:642: error: Possible null pointer dereference: shell
app/core/gimp-contexts.c:65: error: Memory pointed to by 'context' is freed twice.
app/core/gimpdrawable-bucket-fill.c:117: error: Uninitialized variable: color
app/core/gimpdrawable-blend.c:1060: error: Memory leak: _timer
app/core/gimpdata.c:911: error: Memory leak: dirname
app/core/gimpprojection.c:594: error: Memory leak: timer
app/core/gimpprojection.c:595: error: Memory leak: timer
app/core/gimpdashpattern.c:240: error: Memory leak: pattern
@scriptum
scriptum / cppcheck-geany-simplified
Last active December 27, 2015 21:29
cppcheck-geany-simplified
geany-master/plugins/htmlchars.c:804: style: Redundant condition. It is valid to free a NULL pointer.
geany-master/src/build.h:159: style: DCL05-C. Use typedefs of non-pointer types only
geany-master/src/editor.c:2663: style: DCL04-C. Do not declare more than one variable per declaration
geany-master/src/prefix.c:58: style: Redundant condition. It is valid to free a NULL pointer.
geany-master/src/prefix.c:90: style: Redundant condition. It is valid to free a NULL pointer.
geany-master/src/utils.c:948: style: EXP08-C. Ensure pointer arithmetic is used correctly
geany-master/src/win32.c:1056: warning: ENV04-C. Do not call system() if you do not need a command processor
geany-master/tagmanager/ctags/cobol.c:37: style: DCL20-C. Always specify void even if a function accepts no arguments
geany-master/tagmanager/ctags/ctags.c:376: style: Redundant condition. It is valid to free a NULL pointer.
geany-master/tagmanager/ctags/haskell.c:47: style: DCL05-C. Use typedefs of non-pointer types only