-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Use a custom implementation of wcsdup on Windows, so that malloc/free… #7540
Conversation
… overrides from curl_global_init are used for wcsdup correctly.
lib/strdup.c
Outdated
size_t lengthnul; | ||
size_t lengthbytes; | ||
|
||
if (SIZE_MAX - length < 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These overflow checks are probably unnecessary, because presumably the wchar string has a size fitting in size_t. I don't know what your standards are for checks like these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stdint may not be available and shouldn't be necessary. curl_setup defines SIZE_T_MAX, you can use that instead. Also Curl_wcsdup doesn't need so many lines, you can do a single check like
if(length > (SIZE_T_MAX / sizeof(wchar_t)) - 1)
return NULL;
return (wchar_t *)Curl_memdup(src, (length + 1) * sizeof(wchar_t))
Thanks! Didn't know about libcurl having a |
Thanks! |
// sets 'Curl_cwcsdup' to '_wcsdup'
curl_global_init(CURL_GLOBAL_DEFAULT);
curl_global_cleanup();
// doesn't reset 'Curl_cwcsdup' to 'Curl_wcsdup', it's still '_wcsdup'
curl_global_init_mem(CURL_GLOBAL_DEFAULT, m, f, r, s, c); |
If you have found a bug in curl related to this PR then please open a new issue and explain how to reproduce |
… overrides from curl_global_init are used for wcsdup correctly.