From 7ae8eb812fd2c3dcde26d1311b04b894a15e8e23 Mon Sep 17 00:00:00 2001 From: Jilles Tjoelker Date: Wed, 8 May 2024 15:32:52 +0200 Subject: [PATCH] stringFT: Return error message as a second return value If stringFT() fails, return the error message from gdImageStringFT(), which is useful to diagnose and fix the problem. There are more functions where this would be helpful, but this one was the only one where we had problems today. --- luagd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/luagd.c b/luagd.c index 9730ff7..389d589 100644 --- a/luagd.c +++ b/luagd.c @@ -1888,7 +1888,8 @@ static int LgdImageStringFT(lua_State *L) { else im = getImagePtr(L, 1); - if (gdImageStringFT(im, brect, fg, font, size, ang, x, y, str) == NULL) { + const char *error_message = gdImageStringFT(im, brect, fg, font, size, ang, x, y, str); + if (error_message == NULL) { lua_pushnumber(L, brect[0]); lua_pushnumber(L, brect[1]); lua_pushnumber(L, brect[2]); @@ -1901,7 +1902,8 @@ static int LgdImageStringFT(lua_State *L) { } lua_pushnil(L); - return 1; + lua_pushstring(L, error_message); + return 2; }