Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tool_operate.c: fix several problems about the usage of curl_easy_init() #9114

Closed
wants to merge 2 commits into from

Conversation

x2018
Copy link
Contributor

@x2018 x2018 commented Jul 6, 2022

On the one hand, curl_easy_init() returns NULL if some errors happen.
So it is better to check the return of it to propagate the proper status.
Without the check, if curl_easy_init() fails, transfer_per_config() will
return CURLE_UNKNOWN_OPTION since curl_easy_getinfo() returns that status
when the first argument is NULL.

On the other hand, we should call curl_easy_cleanup() to prevent potential
memory leaks on other error handling paths.

On the one hand, curl_easy_init() returns NULL if some errors happen.
So it is better to check the return of it to propagate the proper status.
Without the check, if curl_easy_init() fails, transfer_per_config() will
return CURLE_UNKNOWN_OPTION since curl_easy_getinfo() returns that status
when the first argument is NULL.

On the other hand, we should call curl_easy_cleanup() to prevent potential
memory leaks on other error handling paths.
@jay
Copy link
Member

jay commented Jul 8, 2022

There may some places in the code where we call curl_easy_getinfo without first checking the curl_easy_init return. You could change curl_easy_getinfo to return CURLE_BAD_FUNCTION_ARGUMENT for NULL handle. Regardless though, I'm not opposed to cleaning them up.

…nt and remove the check for curl_easy_init() before curl_easy_getinfo()
@x2018
Copy link
Contributor Author

x2018 commented Jul 8, 2022

Thank you for your suggestion. I removed the check for curl_easy_init() before curl_easy_getinfo(), and made Curl_getinfo() return CURLE_BAD_FUNCTION_ARGUMENT for handling NULL of the first argument.

bagder
bagder approved these changes Jul 10, 2022
@bagder
Copy link
Member

bagder commented Jul 10, 2022

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants