From 6f265ded5d68901ae761ed03b85dc8e9e1238417 Mon Sep 17 00:00:00 2001 From: Alexandre Erwin Ittner Date: Tue, 22 May 2012 00:39:41 -0300 Subject: [PATCH] Fix invalid error report cd:iconv returned an invalid ERROR_UNKNOW code instead of 'nil' on successful conversions. This usually passes unnoticed since the return string is what the user actually expects. --- luaiconv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/luaiconv.c b/luaiconv.c index 0d43524..c5873c1 100644 --- a/luaiconv.c +++ b/luaiconv.c @@ -147,13 +147,14 @@ static int Liconv(lua_State *L) { return 2; /* Unknown error */ } } - } while (ret != (size_t) 0); + } while (ret == (size_t) -1); lua_pushlstring(L, outbufs, obsize - obleft); if (hasone == 1) lua_concat(L, 2); free(outbufs); - return 1; /* Done */ + lua_pushnil(L); + return 2; /* Done */ }