Panu Matilainen 9c6110
commit 5f3598a700e8e028f9140682262869ca319597ee
Panu Matilainen 9c6110
Author: Panu Matilainen <pmatilai@redhat.com>
Panu Matilainen 9c6110
Date:   Fri Sep 6 16:31:25 2013 +0300
Panu Matilainen 9c6110
Panu Matilainen 9c6110
    Fix segfault executing a -p <lua> scriptlet without a body (RhBug:1004062)
Panu Matilainen 9c6110
    
Panu Matilainen 9c6110
    - There are any number of places where this could be fixed, but
Panu Matilainen 9c6110
      to keep the behavior similar to eg /bin/sh scriptlet without a body,
Panu Matilainen 9c6110
      just turn a non-existent script into an empty string.
Panu Matilainen 9c6110
Panu Matilainen 9c6110
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
Panu Matilainen 9c6110
index 0576318..921cc37 100644
Panu Matilainen 9c6110
--- a/rpmio/rpmlua.c
Panu Matilainen 9c6110
+++ b/rpmio/rpmlua.c
Panu Matilainen 9c6110
@@ -526,6 +526,8 @@ int rpmluaRunScript(rpmlua _lua, const char *script, const char *name)
Panu Matilainen 9c6110
     int ret = 0;
Panu Matilainen 9c6110
     if (name == NULL)
Panu Matilainen 9c6110
 	name = "<lua>";
Panu Matilainen 9c6110
+    if (script == NULL)
Panu Matilainen 9c6110
+	script = "";
Panu Matilainen 9c6110
     if (luaL_loadbuffer(L, script, strlen(script), name) != 0) {
Panu Matilainen 9c6110
 	rpmlog(RPMLOG_ERR, _("invalid syntax in lua script: %s\n"),
Panu Matilainen 9c6110
 		 lua_tostring(L, -1));