Details

      Description

      Hi,

      i've just ran cppcheck (http://cppcheck.sourceforge.net/, a static code analyser) on zabbix codebase (svn revision 40328) and it found:

      [src/libs/zbxregexp/gnuregex.c:1176]: (error) Memory leak: compile_stack.stack
      [src/libs/zbxregexp/gnuregex.c:4849]: (error) Memory leak: regs.start
      [src/libs/zbxregexp/gnuregex.c:4849]: (error) Memory leak: regs.end
      [src/libs/zbxregexp/gnuregex.c:2603]: (error) Memory leak: fail_stack.stack
      

      FYI once cppcheck found a memory leak it stop checking for this variable,
      so you have to rerun it after correcting (you have to 'free' before each return)

      to run cppcheck:

      cppcheck --force -j8 . 2> ../cppcheck-zabbix.txt
      

      You can also run it with

      cppcheck --force --enable=all -j7 . 2> ../cppcheck-zabbix2.txt
      

      you will have many more advice but also more false positive

      You should consider running cppcheck before each release

        Activity

        Hide
        Igors Homjakovs (Inactive) added a comment - - edited

        Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-7392 .

        Show
        Igors Homjakovs (Inactive) added a comment - - edited Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBX-7392 .
        Hide
        Aleksandrs Saveljevs added a comment - - edited

        (1) This fixes a false positive:

        Index: src/zabbix_agent/active.c
        ===================================================================
        --- src/zabbix_agent/active.c	(revision 40692)
        +++ src/zabbix_agent/active.c	(working copy)
        @@ -740,7 +740,7 @@
         {
         	const char			*__function_name = "process_value";
         	ZBX_ACTIVE_BUFFER_ELEMENT	*el = NULL;
        -	int				i, ret = FAIL;
        +	int				i = 0, ret = FAIL;
         	size_t				sz;
         
         	zabbix_log(LOG_LEVEL_DEBUG, "In %s() key:'%s:%s' value:'%s'", __function_name, host, key, value);
        

        Igors Homjakovs RESOLVED in r40695

        Aleksandrs Saveljevs CLOSED

        Show
        Aleksandrs Saveljevs added a comment - - edited (1) This fixes a false positive: Index: src/zabbix_agent/active.c =================================================================== --- src/zabbix_agent/active.c (revision 40692) +++ src/zabbix_agent/active.c (working copy) @@ -740,7 +740,7 @@ { const char *__function_name = "process_value" ; ZBX_ACTIVE_BUFFER_ELEMENT *el = NULL; - int i, ret = FAIL; + int i = 0, ret = FAIL; size_t sz; zabbix_log(LOG_LEVEL_DEBUG, "In %s() key:'%s:%s' value:'%s'" , __function_name, host, key, value); Igors Homjakovs RESOLVED in r40695 Aleksandrs Saveljevs CLOSED
        Hide
        Aleksandrs Saveljevs added a comment - - edited

        (2) Please take a look at r40694. It fixes some more warnings and a bit of style.

        Igors Homjakovs Thank you for your fixes. I also fixed some code formatting in r40750.

        RESOLVED

        Aleksandrs Saveljevs Please see r40755. It fixes formatting that was a bit off in r40750. RESOLVED.

        Igors Homjakovs Thank you. I saw your modifications and accept them.

        CLOSED.

        Show
        Aleksandrs Saveljevs added a comment - - edited (2) Please take a look at r40694. It fixes some more warnings and a bit of style. Igors Homjakovs Thank you for your fixes. I also fixed some code formatting in r40750. RESOLVED Aleksandrs Saveljevs Please see r40755. It fixes formatting that was a bit off in r40750. RESOLVED. Igors Homjakovs Thank you. I saw your modifications and accept them. CLOSED.
        Hide
        Igors Homjakovs (Inactive) added a comment -

        Fixed in 2.3.0 (trunk) r40932 and 2.2.2rc1 r40934

        Show
        Igors Homjakovs (Inactive) added a comment - Fixed in 2.3.0 (trunk) r40932 and 2.2.2rc1 r40934
        Hide
        richlv added a comment - - edited

        (3) comment on ZBX-7711 says "gnuregexp.c is used only on Windows."
        is that correct ? if so, server and proxy components should be removed from this issue and changelog entry

        Alexander Vladishev Of course, it is only related to Windows Agent. CLOSED

        <richlv> changelog entry still claims server and proxy are involved. REOPENED

        Igors Homjakovs RESOLVED in r49275 and r49276.

        <richlv> changelog entry in 2.4 branch still claims server and proxy are involved. REOPENED

        Igors Homjakovs RESOLVED in r49301.

        <richlv> thanks, looking good now - CLOSED

        Show
        richlv added a comment - - edited (3) comment on ZBX-7711 says "gnuregexp.c is used only on Windows." is that correct ? if so, server and proxy components should be removed from this issue and changelog entry Alexander Vladishev Of course, it is only related to Windows Agent. CLOSED < richlv > changelog entry still claims server and proxy are involved. REOPENED Igors Homjakovs RESOLVED in r49275 and r49276. < richlv > changelog entry in 2.4 branch still claims server and proxy are involved. REOPENED Igors Homjakovs RESOLVED in r49301. < richlv > thanks, looking good now - CLOSED
        Hide
        MATSUDA Daiki added a comment - - edited

        r40934 fix should be applied to 2.0.x. r48076 too.

        Show
        MATSUDA Daiki added a comment - - edited r40934 fix should be applied to 2.0.x. r48076 too.

          People

          • Assignee:
            Unassigned
            Reporter:
            Etienne CHAMPETIER
          • Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: