Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Constant Memory leak found at this trace #22

Open
kaprakashr opened this issue Jan 19, 2016 · 1 comment
Open

Constant Memory leak found at this trace #22

kaprakashr opened this issue Jan 19, 2016 · 1 comment

Comments

@kaprakashr
Copy link

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)

@kaprakashr
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant