MyFirstContribution.txt leaks memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello everyone!
I was going through the MyFirstContribution tutorial and implemented
its code as an exercise to warm up my git skills.
However, when I pushed the code to my fork on GitHub, I noticed that
it fails the linux-leaks test.
So I fired up the leaks checker that MacOS provides and got a number
of leaks in the tutorial code.
One was that the strbuf commitline was not released, so I was able to
fix that trivially.

However, the stack trace for the second leak shows that the memory
leaks  when git_config() is called on the wt_status struct, which in turn
calls the git_default_config() function. As it must go through my
.gitconfig, I noticed that when it checks for "core.editor", it calls
git_config_string(), where the string is duplicated into the
editor_program variable.

This is precisely where the leak seems to be, as pointed out by the
stack of function calls. I thought that maybe freeing dest as in
free((void *)*dest) in git_config_string() before calling xstrdup()
might free up the leakage (this has been done in a number of places in
the code-base).

While this does free up the leakage, I am getting a number of failures in
the test suite(some of which are occurring even without the changes),
particularly related to setting up bare repositories.

Also, as only the tutorial code's binary(./bin-wrappers/git psuh) that I
implemented leaks memory, I suspect that it is my fault somewhere.

Could anyone point out what is the correct way to free up memory in this case?
Or would the situation warrant adding the call to free() in git_config_string()?

Thanks a lot!
Vinayak




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux