Browse Source

love.graphics.print doesn't stop at \0

Sasha Szpakowski 8 months ago
parent
commit
58000b4e9e
1 changed files with 6 additions and 2 deletions
  1. 6 2
      src/modules/graphics/wrap_Font.cpp

+ 6 - 2
src/modules/graphics/wrap_Font.cpp

@@ -57,7 +57,9 @@ void luax_checkcoloredstring(lua_State *L, int idx, std::vector<love::font::Colo
 			}
 			}
 			else
 			else
 			{
 			{
-				coloredstr.str = luaL_checkstring(L, -1);
+				size_t strl = 0;
+				const char *str = luaL_checklstring(L, -1, &strl);
+				coloredstr.str.assign(str, strl);
 				strings.push_back(coloredstr);
 				strings.push_back(coloredstr);
 			}
 			}
 
 
@@ -66,7 +68,9 @@ void luax_checkcoloredstring(lua_State *L, int idx, std::vector<love::font::Colo
 	}
 	}
 	else
 	else
 	{
 	{
-		coloredstr.str = luaL_checkstring(L, idx);
+		size_t strl = 0;
+		const char *str = luaL_checklstring(L, idx, &strl);
+		coloredstr.str.assign(str, strl);
 		strings.push_back(coloredstr);
 		strings.push_back(coloredstr);
 	}
 	}
 }
 }