From d8df0d6db7441b6e14920a7e16a10e32bdc9c7ae Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Tue, 2 May 2023 10:25:58 +0200 Subject: [PATCH] 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 --- lib/easy.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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); + } } /* -- 2.47.3