summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Jones <pjones@redhat.com>2007-11-02 09:23:05 -0400
committerPeter Jones <pjones@redhat.com>2007-11-02 09:23:05 -0400
commit51f5b6caa8c432d04cb1d33d525495f2d6820b6e (patch)
treee838d31f18eaab1dcc0ffbb8110385c723d5d746
parente1cc5871a0cd351276035d501a0e8b617b0716b7 (diff)
downloadlibrpm-tizen-51f5b6caa8c432d04cb1d33d525495f2d6820b6e.tar.gz
librpm-tizen-51f5b6caa8c432d04cb1d33d525495f2d6820b6e.tar.bz2
librpm-tizen-51f5b6caa8c432d04cb1d33d525495f2d6820b6e.zip
- Fix segfault in %{lua:...}'s rpm_print
- Don't automatically print a newline in rpm_print
-rw-r--r--rpmio/rpmlua.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/rpmio/rpmlua.c b/rpmio/rpmlua.c
index a13f6c8c9..8f2c8c6b3 100644
--- a/rpmio/rpmlua.c
+++ b/rpmio/rpmlua.c
@@ -130,6 +130,7 @@ void rpmluaSetPrintBuffer(rpmlua _lua, int flag)
free(lua->printbuf);
lua->printbuf = NULL;
lua->printbufsize = 0;
+ lua->printbufused = 0;
}
const char *rpmluaGetPrintBuffer(rpmlua _lua)
@@ -745,15 +746,13 @@ static int rpm_print (lua_State *L)
}
lua_pop(L, 1); /* pop result */
}
- lua_pop(L, 1);
if (!lua->storeprint) {
(void) fputs("\n", stdout);
} else {
- if (lua->printbufused+1 >= lua->printbufsize) {
+ if (lua->printbufused+1 > lua->printbufsize) {
lua->printbufsize += 512;
lua->printbuf = xrealloc(lua->printbuf, lua->printbufsize);
}
- lua->printbuf[lua->printbufused++] = '\n';
lua->printbuf[lua->printbufused] = '\0';
}
return 0;