shiyilei / protobuf-c

Automatically exported from code.google.com/p/protobuf-c
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

memory leak in protobuf_c_message_unpack #79

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Hi!
I have found a memory leak in the protobuf_c_message_unpack() function.

There are actually 2 issues.
1. There is an allocation for required_fields_bitmap memory using malloc , 
instead of using the protobuf_c_default_allocator (DO_ALLOC).
2. There is no free() this allocation. (FREE() should be added in all exit 
points.)

What version of the product are you using? On what operating system?
protobuf-c 0.15

Please provide any additional information below.

Thanks
Miry Heller

Original issue reported on code.google.com by miry.hel...@harmonicinc.com on 2 Feb 2012 at 3:54

GoogleCodeExporter commented 8 years ago
Is this the line of code you're talking about? alloca() is a stack allocation. 
You must not free it, it simply falls off the stack when you leave the function 
scope.

  required_fields_bitmap = alloca(required_fields_bitmap_len * sizeof(long));

Original comment by sodab...@gmail.com on 1 Aug 2012 at 9:46