libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
544 stars 305 forks source link

Coverity scan output for xplist.c #122

Closed hadess closed 3 years ago

hadess commented 6 years ago

Tried to figure this out in #121 but couldn't, so filing it here so it doesn't get lost.

libplist-2.0.0/src/xplist.c:991: alloc_fn: Storage is returned from allocation function "plist_new_node".
libplist-2.0.0/src/plist.c:140:5: alloc_fn: Storage is returned from allocation function "node_create".
libplist-2.0.0/libcnary/node.c:50:15: alloc_fn: Storage is returned from allocation function "malloc".
libplist-2.0.0/libcnary/node.c:50:15: var_assign: Assigning: "node" = "malloc(80UL)".
libplist-2.0.0/libcnary/node.c:54:2: noescape: Resource "node" is not freed or pointed-to in function "memset". [Note: The source code implementation of the function has been overridden by a builtin model.]
libplist-2.0.0/libcnary/node.c:78:2: return_alloc: Returning allocated memory "node".
libplist-2.0.0/src/plist.c:140:5: return_alloc_fn: Directly returning storage allocated by "node_create".
libplist-2.0.0/src/xplist.c:991: var_assign: Assigning: "subnode" = storage returned from "plist_new_node(data)".
libplist-2.0.0/src/xplist.c:1251: overwrite_var: Overwriting "subnode" in "subnode = NULL" leaks the storage that "subnode" points to.
# 1249|                       parent = subnode;
# 1250|                   }
# 1251|->                 subnode = NULL;
# 1252|               } else if (closing_tag) {
# 1253|                   if (!node_path) {
nikias commented 3 years ago

I am closing this. I went through the code again and the NULLing of the pointer is totally fine, in all cases in this branch the storage is assigned to either parent to be processed later or added as an actual subnode to a container type.