[Scummvm-git-logs] scummvm master -> 8656e2be9e3b9ebf36904012b3e2829fc8f7bb9f

phcoder phcoder at gmail.com
Sun Nov 1 16:16:13 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:
8656e2be9e HADESCH: Ensure lifecycle of heroNameUTF8


Commit: 8656e2be9e3b9ebf36904012b3e2829fc8f7bb9f
    https://github.com/scummvm/scummvm/commit/8656e2be9e3b9ebf36904012b3e2829fc8f7bb9f
Author: Vladimir Serbinenko (phcoder at google.com)
Date: 2020-11-01T17:16:03+01:00

Commit Message:
HADESCH: Ensure lifecycle of heroNameUTF8

If you encode and do c_str() in the same statement then temporary
object may be freed before c_str result is actually used. So far
it wasn't a problem but let's be safe

Changed paths:
    engines/hadesch/rooms/options.cpp


diff --git a/engines/hadesch/rooms/options.cpp b/engines/hadesch/rooms/options.cpp
index d4337f4e8f..316e7d4103 100644
--- a/engines/hadesch/rooms/options.cpp
+++ b/engines/hadesch/rooms/options.cpp
@@ -416,10 +416,11 @@ private:
 	void performSave() {		
 		int slot = g_vm->firstAvailableSlot();
 		Persistent *persistent = g_vm->getPersistent();
+		Common::String heroNameUTF8 = persistent->_heroName.encode(Common::kUtf8);
 		// UTF-8
 		Common::String descPos = Common::String::format(
 			saveDescs[persistent->_currentRoomId],
-			persistent->_heroName.encode(Common::kUtf8).c_str());
+			heroNameUTF8.c_str());
 		// UTF-8
 		Common::String desc = _typedSlotName.empty() ? descPos
 		    : _typedSlotName + " (" + descPos + ")";




More information about the Scummvm-git-logs mailing list