Re: [PATCH v5 12/44] builtin-am: implement --skip

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

 



On Tue, Jul 14, 2015 at 2:34 AM, Paul Tan <pyokagan@xxxxxxxxx> wrote:
> On Tue, Jul 14, 2015 at 3:05 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
>> All returns before this point leak the memory of `lock_file`.
>
> Yeah, it's intentional. From Documentation/technical/api-lockfile.txt:
>
> * Allocates a `struct lock_file` either as a static variable or on the
>   heap, initialized to zeros. Once you use the structure to call the
>   `hold_lock_file_*` family of functions, it belongs to the lockfile
>   subsystem and its storage must remain valid throughout the life of
>   the program (i.e. you cannot use an on-stack variable to hold this
>   structure).
>
> Thanks,
> Paul

So what I meant to suggest, was to only allocate the memory if we really need it
by moving the allocation further down.

static int clean_index(const unsigned char *head, const unsigned char *remote)
{
       struct lock_file *lock_file;
...
... // includes return -1, which would not leak the memory already allocated
...
       lock_file = xalloc (...);
       hold_locked_index(lock_file, 1);
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]