On 30 May 2014 08:55, Paweł Dziepak <pdziepak@xxxxxxxxxxx> wrote: > 2014-05-29 22:49 GMT+02:00 <jessica.l.hamilton@xxxxxxxxx>: >> Commit: d0592a11644a9f9d1161cee3124e15c956770a41 >> URL: http://cgit.haiku-os.org/haiku/commit/?id=d0592a1 >> Author: Puck Meerburg <puck@xxxxxxxxxxxxx> >> Date: Tue Dec 24 11:08:00 2013 UTC >> Committer: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> >> Commit-Date: Thu May 29 20:45:56 2014 UTC >> >> Fix Coverity bug 605892: Resource leak >> >> Signed-off-by: Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> >> >> ---------------------------------------------------------------------------- >> >> diff --git a/src/system/kernel/posix/xsi_semaphore.cpp >> b/src/system/kernel/posix/xsi_semaphore.cpp >> index 5a48f9d..3e311f3 100644 >> --- a/src/system/kernel/posix/xsi_semaphore.cpp >> +++ b/src/system/kernel/posix/xsi_semaphore.cpp >> @@ -1158,8 +1158,10 @@ _user_xsi_semop(int semaphoreID, struct sembuf *ops, >> size_t numOps) >> if (operation != 0) >> semaphore->Revert(operation); >> } >> - if (result != 0) >> + if (result != 0) { >> + free(operations); >> return result; >> + } >> >> // We have to wait: first enqueue the thread >> // in the appropriate set waiting list, then >> @@ -1246,5 +1248,6 @@ _user_xsi_semop(int semaphoreID, struct sembuf *ops, >> size_t numOps) >> semaphore->SetPid(getpid()); >> } >> } >> + free(operations); >> return result; >> } > > Bugs like that are a good sign that MemoryDeleter should be used here. Just looking at the code, is using the private/shared/AutoDeleter.h header in the kernel posix code okay? I noticed it only makes use of Haiku headers inside private/kernel/util; e.g. there already seems like quite some overlap/duplication of headers between those two locations. Whilst the code builds for my patch, am not sure if it's the right thing to do :) Current patch is at https://gist.github.com/jessicah/623dde6cdf0c49b5f177 for reference.