Not all scriptlets have bodies (eg -p /sbin/ldconfig), dont expand NULLs

This commit is contained in:
Panu Matilainen 2010-03-11 13:38:52 +02:00
parent e34d752b92
commit b5118bad05
2 changed files with 5 additions and 4 deletions

View File

@ -526,11 +526,11 @@ static rpmRC handleOneTrigger(const rpmpsm psm,
.args = args
};
if (script.flags & RPMSCRIPT_EXPAND) {
if (script.body && (script.flags & RPMSCRIPT_EXPAND)) {
macro = rpmExpand(script.body, NULL);
script.body = macro;
}
if (script.flags & RPMSCRIPT_QFORMAT) {
if (script.body && (script.flags & RPMSCRIPT_QFORMAT)) {
qformat = headerFormat(trigH, script.body, NULL);
script.body = qformat;
}

View File

@ -396,13 +396,14 @@ rpmScript rpmScriptFromTag(Header h, rpmTag scriptTag)
script->tag = scriptTag;
rasprintf(&script->descr, "%s(%s)", tag2sln(scriptTag), nevra);
script->body = headerGetAsString(h, scriptTag);
/* macros need to be expanded before possible queryformat */
if (flags & RPMSCRIPT_EXPAND) {
if (script->body && (flags & RPMSCRIPT_EXPAND)) {
char *body = rpmExpand(script->body, NULL);
free(script->body);
script->body = body;
}
if (flags & RPMSCRIPT_QFORMAT) {
if (script->body && (flags & RPMSCRIPT_QFORMAT)) {
/* XXX TODO: handle queryformat errors */
char *body = headerFormat(h, script->body, NULL);
free(script->body);