Re: [PATCH maint] builtin-merge.c: fix memory under-allocation

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

 



Miklos Vajna wrote:
> On Wed, Oct 08, 2008 at 07:07:54PM -0500, Brandon Casey <casey@xxxxxxxxxxxxxxx> wrote:
>> While we're at it, change the allocation to reference the variable it is
>> allocating memory for to try to prevent a similar mistake if the type is
>> changed in the future.
> 
> If this is really a problem, then I think it would be good to mention
> this in Documentation/CodingGuidelines.

That's fine. Though I didn't mean to imply that the memory under-allocation
was caused by a change in variable type in this case. Re-reading my commit
message, maybe it sounds like that.

  Something like this sometimes happens:

-    struct a_struct *foo = xmalloc(sizeof(struct a_struct));
+    struct a_bigr_struct *foo = xmalloc(sizeof(struct a_struct));

  which would be avoided if we had started with:

     struct a_struct *foo = xmalloc(sizeof(*foo));

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

  Powered by Linux