diff --git a/src/script/common/c_converter.cpp b/src/script/common/c_converter.cpp
index 65c3654ae29154a20a209ecde84ec06691022452..df86f2dafe1bff067b71d6d0c58cbf8a3837cf86 100644
--- a/src/script/common/c_converter.cpp
+++ b/src/script/common/c_converter.cpp
@@ -226,8 +226,10 @@ bool getstringfield(lua_State *L, int table,
 	if(lua_isstring(L, -1)){
 		size_t len = 0;
 		const char *ptr = lua_tolstring(L, -1, &len);
-		result.assign(ptr, len);
-		got = true;
+		if (ptr) {
+			result.assign(ptr, len);
+			got = true;
+		}
 	}
 	lua_pop(L, 1);
 	return got;