-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
StlLCMapStringA.cpp
: Does __crtLCMapStringA()
have bogus error paths?
#4984
Comments
Lines 77 to 90 in 1e312b3
|
Ah, but we pass STL/stl/src/StlLCMapStringA.cpp Lines 80 to 93 in 1e312b3
We then fall through to the end of the function, where we use the "successful" |
Quote from the offline documentation I still use when the offline is bogus (as I thing currently happens)
|
While fixing a CodeQL warning in
__crtLCMapStringA()
, I'm seeing code that makes no sense:STL/stl/src/StlLCMapStringA.cpp
Lines 28 to 122 in 1e312b3
Specifically, every single
return retval;
(except for the last one, which is the success path) looks like it's a failure case where we should actually be returning 0 (failure).Early on, if we can't allocate an
inwbuffer
, we return 0, which makes total sense:STL/stl/src/StlLCMapStringA.cpp
Lines 62 to 65 in 1e312b3
But later, if we can't allocate an
outwbuffer
, wereturn retval;
, which makes no sense whatsoever:STL/stl/src/StlLCMapStringA.cpp
Lines 99 to 102 in 1e312b3
Similarly for the other cases.
Notes:
return 0;
without a thorough analysis and evidence that this won't damage behavior in some way._CRTIMP2
), but it's used only within the STL and is not user-visible. I believe it's never been user-visible in the VS 2015+ era (need to confirm this). If it was never user-visible, then we need to maintain its signature for dllexport validation but we need not preserve its behavior.LCMapStringEx
forLCMAP_SORTKEY
(this is what I'm looking at for CodeQL). Onlyxstrxfrm.cpp
has 2 calls withLCMAP_SORTKEY
, so if we ever gain the understanding/courage to mess with this, we should consider splitting up this function's behavior.The text was updated successfully, but these errors were encountered: