tevent_set_default_backend will cause memory leak.

Galen(liugang) galen.gang.liu at gmail.com
Sun Dec 30 21:17:52 MST 2012


Hi All:

In tevent-0.9.17/tevent.c +101 of tevent-0.9.17.tar.gz

/*
  set the default event backend
 */
void tevent_set_default_backend(const char *backend)
{
    talloc_free(tevent_default_backend);
    tevent_default_backend = talloc_strdup(NULL, backend);
}


We can see that  it use talloc_strdup to malloc a memory block, but there
isn't any other place to free it.


My Test file is:

#include <stdio.h>
#include <talloc.h>
#include <tevent.h>

int main(int argc, char *argv[])
{
        tevent_set_default_backend("epoll");
        return 0;
}

gcc -o tevent_test1 tevent_test1.c -ltevent
valgrind ./tevent_test1

This is output log of valgrind.

==18444== HEAP SUMMARY:
==18444==     in use at exit: 54 bytes in 1 blocks
==18444==   total heap usage: 1 allocs, 0 frees, 54 bytes allocated
==18444==
==18444== LEAK SUMMARY:
==18444==    definitely lost: 0 bytes in 0 blocks
==18444==    indirectly lost: 0 bytes in 0 blocks
==18444==      possibly lost: 54 bytes in 1 blocks
==18444==    still reachable: 0 bytes in 0 blocks
==18444==         suppressed: 0 bytes in 0 blocks


-Galen


More information about the samba-technical mailing list