Be more careful about errors in lua rpm vercmp()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 10 Feb 2009 12:11:28 +0000 (14:11 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 11 Feb 2009 10:32:24 +0000 (12:32 +0200)
lib/rpmliblua.c

index 6876d2f..046ed31 100644 (file)
 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[] = {