[haiku-commits] Re: haiku: hrev47280 - headers/os/support src/build/libroot headers/posix/netinet src/system/kernel/posix

  • From: Paweł Dziepak <pdziepak@xxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 29 May 2014 22:55:53 +0200

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.

Paweł

Other related posts: