diff --git a/src/common/utf8.cpp b/src/common/utf8.cpp index df702fa2c..6bd0220cb 100644 --- a/src/common/utf8.cpp +++ b/src/common/utf8.cpp @@ -36,12 +36,12 @@ namespace love // Convert to UTF-8. int ok = WideCharToMultiByte(CP_UTF8, 0, wstr, wide_len, utf8_str, utf8_size, 0, 0); - if(!ok) - { - delete [] utf8_str; - } + std::string ret; + if (ok) + ret = utf8_str; - return ok ? std::string(utf8_str) : std::string(); + delete utf8_str; + return ret; } void replace_char(std::string & str, char find, char replace) @@ -57,4 +57,4 @@ namespace love } // love -#endif // LOVE_WINDOWS \ No newline at end of file +#endif // LOVE_WINDOWS diff --git a/src/modules/graphics/opengl/PixelEffect.h b/src/modules/graphics/opengl/PixelEffect.h index 79f6e8941..6e60df310 100644 --- a/src/modules/graphics/opengl/PixelEffect.h +++ b/src/modules/graphics/opengl/PixelEffect.h @@ -14,7 +14,7 @@ namespace graphics namespace opengl { // A fragment shader - class PixelEffect : public Volatile // Volatile? + class PixelEffect : public Volatile, public Object { public: PixelEffect(const std::string& code); diff --git a/src/modules/graphics/opengl/wrap_Graphics.cpp b/src/modules/graphics/opengl/wrap_Graphics.cpp index 86f1c3261..883379878 100644 --- a/src/modules/graphics/opengl/wrap_Graphics.cpp +++ b/src/modules/graphics/opengl/wrap_Graphics.cpp @@ -245,6 +245,7 @@ namespace opengl int w_newFont1(lua_State * L) { + Data * font_data = NULL; // Convert to File, if necessary. if(lua_isstring(L, 1)) luax_convobj(L, 1, "filesystem", "newFile"); @@ -252,15 +253,14 @@ namespace opengl // Convert to Data, if necessary. if(luax_istype(L, 1, FILESYSTEM_FILE_T)) { love::filesystem::File * f = luax_checktype(L, 1, "File", FILESYSTEM_FILE_T); - Data * d; try { - d = f->read(); + font_data = f->read(); } catch (love::Exception & e) { return luaL_error(L, e.what()); } lua_remove(L, 1); // get rid of the file - luax_newtype(L, "Data", DATA_T, (void*)d); + luax_newtype(L, "Data", DATA_T, (void*)font_data); lua_insert(L, 1); // put it at the bottom of the stack } @@ -270,6 +270,9 @@ namespace opengl luax_convobj(L, idxs, 2, "font", "newRasterizer"); } + if (font_data) + font_data->release(); + love::font::Rasterizer * rasterizer = luax_checktype(L, 1, "Rasterizer", FONT_RASTERIZER_T); // Create the font.