From d0595eaa8ad8a9155a0fa4b0b6f4b3d5ed08b2e8 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 10 Feb 2009 14:11:28 +0200 Subject: [PATCH] Be more careful about errors in lua rpm vercmp() --- lib/rpmliblua.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/rpmliblua.c b/lib/rpmliblua.c index 6876d2f..046ed31 100644 --- a/lib/rpmliblua.c +++ b/lib/rpmliblua.c @@ -12,14 +12,15 @@ static int rpm_vercmp(lua_State *L) { const char *v1, *v2; - int rc; + int rc = 0; v1 = luaL_checkstring(L, 1); v2 = luaL_checkstring(L, 2); - - rc = rpmvercmp(v1, v2); - lua_pushinteger(L, rc); - return 1; + if (v1 && v2) { + lua_pushinteger(L, rpmvercmp(v1, v2)); + rc = 1; + } + return rc; } static const luaL_reg luarpmlib_f[] = { -- 2.7.4