From: Daniel Stenberg Date: Tue, 2 May 2023 08:25:58 +0000 (+0200) Subject: easy_cleanup: require a "good" handle to act X-Git-Tag: curl-8_1_0~43 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d8df0d6db7441b6e14920a7e16a10e32bdc9c7ae;p=thirdparty%2Fcurl.git easy_cleanup: require a "good" handle to act By insisting that the passed in handle is "good" (the magic number is intact), this can limit the potential damage if a bad pointer is passed in. Like when this function is called twice on the same handle pointer. Ref: #10964 Closes #11061 --- diff --git a/lib/easy.c b/lib/easy.c index a6c32f51e6..d72a2a88d3 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -787,14 +787,12 @@ CURLcode curl_easy_perform_ev(struct Curl_easy *data) */ void curl_easy_cleanup(struct Curl_easy *data) { - SIGPIPE_VARIABLE(pipe_st); - - if(!data) - return; - - sigpipe_ignore(data, &pipe_st); - Curl_close(&data); - sigpipe_restore(&pipe_st); + if(GOOD_EASY_HANDLE(data)) { + SIGPIPE_VARIABLE(pipe_st); + sigpipe_ignore(data, &pipe_st); + Curl_close(&data); + sigpipe_restore(&pipe_st); + } } /*