News for hackers. Stuff that matters.
Re:Finding bugs in Tarsnap by programmernews3 on Thursday July 02, 2015 @05:36PM (#9821839)
Aren't free()'s senseless before code exits?
Re:Finding bugs in Tarsnap by cperciva on Thursday July 02, 2015 @05:48PM (#9821917)
Yes, if you know that the process is going to exit. In this case, the missing free is in a function which is about a dozen calls down in the stack, and I know that it's harmless right now because I've looked at the code and verified that an error there will always result in tarsnap exiting; but if I don't fix this now it's quite possible that in the future I'll have code which uses that function but can tolerate it failing.
Re:Finding bugs in Tarsnap by programmernews3 on Thursday July 02, 2015 @06:00PM (#9822002)
I think I understand. Function, which could be used independently should free all used resources.

If a function is very project-specific and has no purpose to being used independently it may be worth considering declaring it static, right?

Re:Finding bugs in Tarsnap by cperciva on Friday July 03, 2015 @02:03AM (#9823790)
"static" is a different concept -- that marks a function as not being used from outside of that compilation unit (aka .c file). This particular function was used from outside of that file, but was unlikely to be reused in a different project.
Re:Finding bugs in Tarsnap by syllogism on Thursday July 02, 2015 @05:40PM (#9821865)
It's best to be rigorous about it in case you refactor or export the function, and to make sure you get a green light from valgrind.