]> git.ipfire.org Git - thirdparty/curl.git/commit
OS400: handle memory error in list conversion
authorDaniel Gustafsson <daniel@yesql.se>
Thu, 13 Dec 2018 09:15:00 +0000 (10:15 +0100)
committerDaniel Gustafsson <daniel@yesql.se>
Thu, 13 Dec 2018 09:15:00 +0000 (10:15 +0100)
commita58b27740fd78fee88b35104fa71b7019280ccff
tree0dc220787d954029b296d5797d161d609aa42f22
parent7a09b52c98ac8d840a8a9907b1a1d9a9e684bcf5
OS400: handle memory error in list conversion

Curl_slist_append_nodup() returns NULL when it fails to create a new
item for the specified list, and since the coding here reassigned the
new list on top of the old list it would result in a dangling pointer
and lost memory. Also, in case we hit an allocation failure at some
point during the conversion, with allocation succeeding again on the
subsequent call(s) we will return a truncated list around the malloc
failure point. Fix by assigning to a temporary list pointer, which can
be checked (which is the common pattern for slist appending), and free
all the resources on allocation failure.

Closes #3372
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
packages/OS400/ccsidcurl.c