Fix possible 0 pointer access
authorsapier <Sapier at GMX dot net>
Sun, 23 Jun 2013 14:09:02 +0000 (16:09 +0200)
committerkwolekr <kwolekr@minetest.net>
Wed, 3 Jul 2013 00:01:48 +0000 (20:01 -0400)
src/script/common/c_converter.cpp

index 65c3654ae29154a20a209ecde84ec06691022452..df86f2dafe1bff067b71d6d0c58cbf8a3837cf86 100644 (file)
@@ -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;