Fix %patch and %autopatch

* build/parsePrep.c (doPatch): Do not pass null pointer to sprintf.
(doAutopatchMacro): Do not pass null pointer to strcmp.

Fixes: 9c18a402 ("Make %autopatch and %patch accept -pg")
This commit is contained in:
Дмитрий Левин 2020-01-04 10:43:44 +00:00
parent 6da99494b5
commit 252df9b61a

View File

@ -89,7 +89,7 @@ static int checkOwners(const char * urlfn)
char args[BUFSIZ];
sprintf(args, "%s%s-p%s",
arg_patch_flags, *arg_patch_flags ? " ": "", strip);
arg_patch_flags, *arg_patch_flags ? " ": "", strip ?: "0");
if (silent)
strcat(args, " -s");
if (db) {
@ -486,7 +486,7 @@ static int doAutopatchMacro(Spec spec, const char *line)
return RPMERR_BADSPEC;
}
if (strcmp(opt_p, "g") && parseNum(opt_p, NULL)) {
if (opt_p && strcmp(opt_p, "g") && parseNum(opt_p, NULL)) {
rpmError(RPMERR_BADSPEC,
_("line %d: Bad arg to %%autopatch -p: %s\n"),
spec->lineNum, spec->line);