← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1815277-persistence-memory-leak into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1815277-persistence-memory-leak into lp:widelands.

Commit message:
Fix a memory leak in persistence.cc

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1815277 in widelands: "Memory leak in persistence.cc while loading game"
  https://bugs.launchpad.net/widelands/+bug/1815277

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1815277-persistence-memory-leak/+merge/362963

There is still a second leak on the same line that I didn't manage to fix.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1815277-persistence-memory-leak into lp:widelands.
=== modified file 'src/scripting/persistence.cc'
--- src/scripting/persistence.cc	2018-04-07 16:59:00 +0000
+++ src/scripting/persistence.cc	2019-02-11 08:25:08 +0000
@@ -48,10 +48,10 @@
 }
 
 const char* LuaReader(lua_State* /* L */, void* userdata, size_t* bytes_read) {
-	LuaReaderHelper* helper = static_cast<LuaReaderHelper*>(userdata);
+	const LuaReaderHelper& helper = *static_cast<LuaReaderHelper*>(userdata);
 
-	*bytes_read = helper->data_len;
-	return helper->data.get();
+	*bytes_read = helper.data_len;
+	return helper.data.get();
 }
 
 }  // namespace


Follow ups