Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-3719

Found two memory leaks in cf-key using valgrind

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.15.5, 3.18.1, 3.19.0
    • Component/s: cf-key
    • Labels:
      None
    • Story Points:
      0

      Description

      Memory allocated in core/cf-key/cf-key.c:145 in function main was never freed

      GenericAgentConfig *config = CheckOpts(argc, argv);

       

      Memory allocated in core/cf-key/cf-key.c:146 in function main was never freed

      EvalContext *ctx = EvalContextNew();

       

      Valgrind output:

      root@hub core $ valgrind --leak-check=full /var/cfengine/bin/cf-key -p /var/cfengine/ppkeys/localhost.pub 
      ==298582== Memcheck, a memory error detector
      ==298582== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
      ==298582== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
      ==298582== Command: /var/cfengine/bin/cf-key -p /var/cfengine/ppkeys/localhost.pub
      ==298582== 
      MD5=e895bd0d86a9ab343921bc561241f604
      ==298582== 
      ==298582== HEAP SUMMARY:
      ==298582==     in use at exit: 120,973 bytes in 3,848 blocks
      ==298582==   total heap usage: 14,873 allocs, 11,025 frees, 4,486,164 bytes allocated
      ==298582== 
      ==298582== 270 (192 direct, 78 indirect) bytes in 1 blocks are definitely lost in loss record 1,351 of 1,413
      ==298582==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==298582==    by 0x48FC39C: xmalloc (alloc.c:43)
      ==298582==    by 0x48D2475: GenericAgentConfigNewDefault (generic_agent.c:2479)
      ==298582==    by 0x10A9DC: CheckOpts (cf-key.c:271)
      ==298582==    by 0x10A9DC: main (cf-key.c:145)
      ==298582== 
      ==298582== 120,624 (184 direct, 120,440 indirect) bytes in 1 blocks are definitely lost in loss record 1,413 of 1,413
      ==298582==    at 0x483DD99: calloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
      ==298582==    by 0x48FC3D4: xcalloc (alloc.c:48)
      ==298582==    by 0x48AE609: EvalContextNew (eval_context.c:1015)
      ==298582==    by 0x10ABCC: main (cf-key.c:146)
      ==298582== 
      ==298582== LEAK SUMMARY:
      ==298582==    definitely lost: 376 bytes in 2 blocks
      ==298582==    indirectly lost: 120,518 bytes in 3,843 blocks
      ==298582==      possibly lost: 0 bytes in 0 blocks
      ==298582==    still reachable: 79 bytes in 3 blocks
      ==298582==         suppressed: 0 bytes in 0 blocks
      ==298582== Reachable blocks (those to which a pointer was found) are not shown.
      ==298582== To see them, rerun with: --leak-check=full --show-leak-kinds=all
      ==298582== 
      ==298582== For lists of detected and suppressed errors, rerun with: -s
      ==298582== ERROR SUMMARY: 2 errors from 2 contexts (suppressed: 0 from 0)
      

        Attachments

          Activity

            People

            Assignee:
            larsewi Lars Erik Wik
            Reporter:
            larsewi Lars Erik Wik
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: