[Scummvm-git-logs] scummvm master -> 41f3d4b488069ecc153a7aa06f8f13735c45d23d
sev-
sev at scummvm.org
Tue Jun 9 21:01:51 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
41f3d4b488 COMMON: Encoding::convertIconv - check errors on last call to `iconv`
Commit: 41f3d4b488069ecc153a7aa06f8f13735c45d23d
https://github.com/scummvm/scummvm/commit/41f3d4b488069ecc153a7aa06f8f13735c45d23d
Author: Zvika Haramaty (haramaty.zvika at gmail.com)
Date: 2020-06-09T23:01:47+02:00
Commit Message:
COMMON: Encoding::convertIconv - check errors on last call to `iconv`
There was a bug when trying to convert the Hebrew string "\e0\e1\e2"
from WINDOWS-1255 to UTF-32LE, because there was a last call to
`iconv` with `NULL`s, without error checking, and buffer needed to
be extended for that last one call.
Now this call is inserted to the main `iconv` loop, with error checking.
Changed paths:
common/encoding.cpp
diff --git a/common/encoding.cpp b/common/encoding.cpp
index efd1ae0d95..80fe8230e0 100644
--- a/common/encoding.cpp
+++ b/common/encoding.cpp
@@ -225,7 +225,7 @@ char *Encoding::convertIconv(const char *to, const char *from, const char *strin
char *dst = buffer;
bool error = false;
- while (inSize > 0) {
+ while (true) {
if (iconv(iconvHandle, &src, &inSize, &dst, &outSize) == ((size_t)-1)) {
// from SDL's implementation of SDL_iconv_string (slightly altered)
if (errno == E2BIG) {
@@ -244,9 +244,18 @@ char *Encoding::convertIconv(const char *to, const char *from, const char *strin
error = true;
break;
}
+ } else {
+ // we've successfully finished, after the last call with NULLs
+ if (inSize == 0 && src == NULL) {
+ break;
+ }
+ }
+ if (inSize == 0) {
+ // we're at the end - call one last time with NULLs
+ src = NULL;
}
}
- iconv(iconvHandle, NULL, NULL, &dst, &outSize);
+
// Add a zero character to the end. Hopefuly UTF32 uses the most bytes from
// all possible encodings, so add 4 zero bytes.
buffer = (char *)realloc(buffer, stringSize + 4);
More information about the Scummvm-git-logs
mailing list