Skip to content

Constant Memory leak found at this trace #22

Open

Description

@kaprakashr

Constant Memory leak found at this trace.
Every time we try to search in CLI,

==7781== LEAK SUMMARY:

==7781== definitely lost: 114 bytes in 20 blocks
==7781== 114 bytes in 20 blocks are definitely lost in loss record 85 of 90

Trace

==7781== at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==7781== by 0x4E3971F: cli_parse_line.constprop.5 (libcli.c:670)
==7781== by 0x4E3CD13: cli_loop (libcli.c:989)
==7781== by 0x4010A1: main (in /home/kalyan/cloutra/src/cli/a.out)

Activity

  1. kaprakashr commented on Jan 19, 2016

    @kaprakashr
    Author

    Function to be fixed

    cli_parse_inline

    Snap

    while (nwords < max_words - 1)
    {
        if (!*p || *p == inquote || (word_start && !inquote && (isspace(*p) || *p == '|')))
        {
            if (word_start)
            {
                int len = p - word_start;
    
                memcpy(words[nwords] = malloc(len + 1), word_start, len); <== later, this is not freed properly
                words[nwords++][len] = 0;
            }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions