Commit: 5dcc52a486f27867bdb685a39e10fadc9e6afa6f
Parent: d79e429a9fc3c37b3a25fcde474c242d8b094bcc
Author: Bastien Nocera <hadess@hadess.net>
Committer: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Date: 2024-07-03 17:37:38
Tree: 9d2cc5878e199bfcbf1f7df318be2835fe83a18d

sdp: Fix memory leak in sdp_data_alloc*() Make sure to free already allocated memory if we run out of memory before the end of the loop. Error: RESOURCE_LEAK (CWE-772): [#def8] [important] lib/sdp.c:542:4: alloc_fn: Storage is returned from allocation function "sdp_data_alloc". lib/sdp.c:542:4: var_assign: Assigning: "data" = storage returned from "sdp_data_alloc(dtd, values[i])". lib/sdp.c:550:4: var_assign: Assigning: "seq" = "data". lib/sdp.c:552:3: var_assign: Assigning: "curr" = "data". lib/sdp.c:553:2: out_of_scope: Variable "data" goes out of scope. lib/sdp.c:552:3: overwrite_var: Overwriting "curr" in "curr = data". lib/sdp.c:545:4: leaked_storage: Variable "seq" going out of scope leaks the storage it points to. 543| 544| if (!data) 545|-> return NULL; 546| 547| if (curr)

Diffstat

M lib/sdp.c | 8 ++++++- -

1 files changed, 6 insertions(+), 2 deletions(-)

View Full Diff | Patch