Index: cpp/common/realloc-free0size.cpp
===================================================================
--- cpp/common/realloc-free0size.cpp	(revision 1314)
+++ cpp/common/realloc-free0size.cpp	(revision 1314)
@@ -0,0 +1,25 @@
+// This file is a part of Framsticks SDK.  http://www.framsticks.com/
+// Copyright (C) 2023-2024  Maciej Komosinski and Szymon Ulatowski.
+// See LICENSE.txt for details.
+
+#include "realloc-free0size.h"
+#include <common/log.h>
+
+// https://stackoverflow.com/questions/16759849/using-realloc-x-0-instead-of-free-and-using-malloc-with-length-of-a-string
+void *realloc_free0size(void *ptr, size_t size)
+{
+	// special case begin
+	if (ptr && size == 0)
+	{
+		free(ptr);
+		return NULL;
+	}
+	// special case end
+
+	void *tmp = realloc(ptr, size);
+	if (size != 0 && tmp == NULL)
+	{
+		logPrintf("", "realloc_free0size", LOG_CRITICAL, "realloc(%zd) failed.", size);
+	}
+	return tmp;
+}
Index: cpp/common/realloc-free0size.h
===================================================================
--- cpp/common/realloc-free0size.h	(revision 1314)
+++ cpp/common/realloc-free0size.h	(revision 1314)
@@ -0,0 +1,13 @@
+// This file is a part of Framsticks SDK.  http://www.framsticks.com/
+// Copyright (C) 2023-2024  Maciej Komosinski and Szymon Ulatowski.
+// See LICENSE.txt for details.
+
+#ifndef _COMMON_REALLOC_FREE0SIZE_H_
+#define _COMMON_REALLOC_FREE0SIZE_H_
+
+#include <stdlib.h>
+
+// realloc() implementation that behaves like free() when size==0 (consistently on all platforms)
+void *realloc_free0size(void *ptr, size_t size);
+
+#endif
Index: cpp/frams/Makefile-SDK
===================================================================
--- cpp/frams/Makefile-SDK	(revision 1313)
+++ cpp/frams/Makefile-SDK	(revision 1314)
@@ -9,5 +9,5 @@
 sdk_tests: $(SDK_TESTS)
 
-CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Werror=return-type
+CXXWARNINGS=-Wall -Wno-parentheses -Wno-overloaded-virtual -Wno-format -Wno-invalid-offsetof -Werror=return-type
 
 SDK_BUILD_CONFIG= -include frams/config/sdk-build-config.h
Index: cpp/frams/Makefile-SDK-files
===================================================================
--- cpp/frams/Makefile-SDK-files	(revision 1313)
+++ cpp/frams/Makefile-SDK-files	(revision 1314)
@@ -41,5 +41,5 @@
 NN_LAYOUT_OBJS=frams/canvas/nn_layout_model.o frams/canvas/nn_simple_layout.o frams/canvas/nn_smart_layout.o
 
-SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/param/paramlist.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/log.o common/util-string.o common/util-file.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o common/loggers/loggers.o frams/param/paramobj.o frams/genetics/genooperators.o common/nonstd_math.o frams/util/validitychecks.o common/Convert.o frams/util/rndutil.o common/virtfile/stringfile.o common/virtfile/stdinoutfilesystem.o $(PRINTFLOAT_OBJS)
+SDK_OBJS=frams/util/list.o frams/util/advlist.o frams/param/param.o frams/param/paramlist.o frams/util/sstring.o frams/util/sstringutils.o frams/util/3d.o frams/vm/classes/3dobject.o frams/model/model.o frams/model/modelparts.o frams/neuro/neurolibrary.o frams/genetics/geno.o frams/genetics/genoconv.o frams/util/extvalue.o frams/vm/classes/collectionobj.o frams/util/hashtable.o common/log.o common/util-string.o common/util-file.o common/nonstd_stdio.o frams/util/callbacks.o frams/param/syntparam.o frams/util/multirange.o frams/util/multimap.o frams/param/paramtabobj.o common/loggers/loggers.o frams/param/paramobj.o frams/genetics/genooperators.o common/nonstd_math.o frams/util/validitychecks.o common/Convert.o frams/util/rndutil.o common/virtfile/stringfile.o common/virtfile/stdinoutfilesystem.o common/realloc-free0size.o $(PRINTFLOAT_OBJS)
 
 STDOUT_LOGGER_OBJS=common/virtfile/virtfile.o common/loggers/loggertostdout.o common/console.o 
Index: cpp/frams/util/list.h
===================================================================
--- cpp/frams/util/list.h	(revision 1313)
+++ cpp/frams/util/list.h	(revision 1314)
@@ -1,4 +1,4 @@
 // This file is a part of Framsticks SDK.  http://www.framsticks.com/
-// Copyright (C) 1999-2018  Maciej Komosinski and Szymon Ulatowski.
+// Copyright (C) 1999-2024  Maciej Komosinski and Szymon Ulatowski.
 // See LICENSE.txt for details.
 
@@ -9,4 +9,5 @@
 #include <string.h>
 #include <common/nonstd.h>
+#include <common/realloc-free0size.h>
 
 //#define SLISTSTATS
@@ -44,9 +45,9 @@
 		if (mem || x)
 		{
-			mem = (T*)realloc(mem, x*sizeof(T));
+			mem = (T*)realloc_free0size(mem, x*sizeof(T));
 #ifdef SLISTSTATS
 			SListStats::stats.allocations++;
 			SListStats::stats.copied += sizeof(T)*min(x, have);
-#endif	
+#endif
 		}
 		have = x;
@@ -150,5 +151,6 @@
 	{
 		setSize(src.size());
-		memcpy(mem, src.mem, src.size()*sizeof(T));
+		if (mem != NULL)
+			memcpy(mem, src.mem, src.size()*sizeof(T));
 	}
 	void operator+=(const SListTempl<T>&src) ///< append src contents
Index: cpp/frams/util/sstring-simple.cpp
===================================================================
--- cpp/frams/util/sstring-simple.cpp	(revision 1313)
+++ cpp/frams/util/sstring-simple.cpp	(revision 1314)
@@ -3,4 +3,5 @@
 #include <assert.h>
 #include <common/nonstd_math.h>
+#include <common/realloc-free0size.h>
 
 #ifdef __ANDROID__
@@ -52,5 +53,5 @@
 {
 	if (newsize == allocated) return;
-	txt = (char*)realloc(txt, newsize);
+	txt = (char*)realloc_free0size(txt, newsize);
 	allocated = newsize;
 }
