[Scummvm-git-logs] scummvm branch-2-1 -> 1bd513637a112f62e6acaedb2512fbc7f1265e1a

criezy criezy at scummvm.org
Mon Jan 6 17:53:06 UTC 2020


This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cf10461d04 README: Add Configuration File Location for iOS
1bd513637a WIN32: Fix free being used on arrays allocated with new


Commit: cf10461d041d28979c1f2b2f66e7f366ba59266c
    https://github.com/scummvm/scummvm/commit/cf10461d041d28979c1f2b2f66e7f366ba59266c
Author: D G Turner (digitall at scummvm.org)
Date: 2020-01-06T17:42:10Z

Commit Message:
README: Add Configuration File Location for iOS

Changed paths:
    README.md


diff --git a/README.md b/README.md
index 4309e5f..2709ff8 100644
--- a/README.md
+++ b/README.md
@@ -2545,6 +2545,12 @@ previous default location of `~/.scummvmrc` will be kept.
 `~/Library/Preferences/ScummVM Preferences` (here, `~` refers to your
 home directory)
 
+**iOS:**
+
+
+For sandboxed version: `/Preferences`
+Otherwise: `/var/mobile/Library/ScummVM/Preferences`
+
 **Others:**
 
 `scummvm.ini` in the current directory


Commit: 1bd513637a112f62e6acaedb2512fbc7f1265e1a
    https://github.com/scummvm/scummvm/commit/1bd513637a112f62e6acaedb2512fbc7f1265e1a
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2020-01-06T17:48:32Z

Commit Message:
WIN32: Fix free being used on arrays allocated with new

Changed paths:
    backends/platform/sdl/win32/win32.cpp


diff --git a/backends/platform/sdl/win32/win32.cpp b/backends/platform/sdl/win32/win32.cpp
index e7dc2af..e52525e 100644
--- a/backends/platform/sdl/win32/win32.cpp
+++ b/backends/platform/sdl/win32/win32.cpp
@@ -459,9 +459,6 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
 	}
 
 	// Add ending zeros
-	char *wString = (char *) calloc(sizeof(char), length + 2);
-	memcpy(wString, string, length);
-
 	WCHAR *tmpStr;
 	if (Common::String(from).hasPrefixIgnoreCase("utf-16")) {
 		// Allocate space for string and 2 ending zeros
@@ -474,11 +471,20 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
 		}
 		memcpy(tmpStr, string, length);
 	} else {
-		tmpStr = Win32::ansiToUnicode(string, Win32::getCodePageId(from));
+		// Win32::ansiToUnicode uses new to allocate the memory. We need to copy it into an array
+		// allocated with malloc as it is going to be freed using free.
+		WCHAR *tmpStr2 = Win32::ansiToUnicode(string, Win32::getCodePageId(from));
+		if (!tmpStr2) {
+			if (newString != nullptr)
+				free(newString);
+			return nullptr;
+		}
+		size_t size = wcslen(tmpStr2) + 1; // +1 for the terminating null wchar
+		tmpStr = (WCHAR *) malloc(sizeof(WCHAR) * size);
+		memcpy(tmpStr, tmpStr2, sizeof(WCHAR) * size);
+		delete[] tmpStr2;
 	}
 
-	free(wString);
-
 	if (newString != nullptr)
 		free(newString);
 
@@ -492,7 +498,15 @@ char *OSystem_Win32::convertEncoding(const char* to, const char *from, const cha
 	} else {
 		result = Win32::unicodeToAnsi(tmpStr, Win32::getCodePageId(to));
 		free(tmpStr);
-		return result;
+		if (!result)
+			return nullptr;
+		// Win32::unicodeToAnsi uses new to allocate the memory. We need to copy it into an array
+		// allocated with malloc as it is going to be freed using free.
+		size_t size = strlen(result) + 1;
+		char *resultCopy = (char *) malloc(sizeof(char) * size);
+		memcpy(resultCopy, result, sizeof(char) * size);
+		delete[] result;
+		return resultCopy;
 	}
 }
 




More information about the Scummvm-git-logs mailing list