cissp@bryongloden.com wrote:
Full_Name: Bryon Gloden, CISSP. Version: OS: URL: ftp://ftp.openldap.org/incoming/ Submission from: (NULL) (161.133.194.55)
Greetings. On line numbers 123 and 134 of liblmdb/midl.c (https://github.com/LMDB/lmdb/blob/mdb.master/libraries/liblmdb/midl.c) there are two common realloc() mistakes. Passing one pointer into realloc() and assigning the result directly into that same pointer variable can cause a memory leak if the reallocation fails, because the original allocation will still exist. The correct way to do this is to use a temporary pointer variable.
This is all false.
On line number 123 we are shrinking the memory region - this will never fail. At worst it can only return the original pointer unchanged.
On line number 134 we are leaving the original pointer unchanged on failure, it is not leaked. The caller can free it if it wants to.
Closing this ITS.