From 50ef054902618edec7a29f5b3b5cb4ae2e12a20f Mon Sep 17 00:00:00 2001 From: Jindrich Novy Date: Thu, 25 Sep 2008 19:30:47 +0200 Subject: [PATCH] Use safer xstrdup() instead of strdup() wherever possible --- build/parsePrep.c | 2 +- lib/rpmlock.c | 2 +- python/rpmts-py.c | 2 +- rpmio/rpmhook.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build/parsePrep.c b/build/parsePrep.c index bfef325..54877fb 100644 --- a/build/parsePrep.c +++ b/build/parsePrep.c @@ -434,7 +434,7 @@ static rpmRC doPatchMacro(rpmSpec spec, const char *line) if (strstr(line+6, " -P") == NULL) rasprintf(&buf, "%%patch -P %d %s", INT_MAX, line + 6); /* INT_MAX denotes not numbered %patch */ else - buf = strdup(line); /* it is not numberless patch because -P is present */ + buf = xstrdup(line); /* it is not numberless patch because -P is present */ } poptParseArgvString(buf, &argc, &argv); free(buf); diff --git a/lib/rpmlock.c b/lib/rpmlock.c index 22dfc34..624ec99 100644 --- a/lib/rpmlock.c +++ b/lib/rpmlock.c @@ -35,7 +35,7 @@ static rpmlock rpmlock_new(const char *rootdir) if (rpmlock_path == NULL) { char * t = rpmGenPath(rootdir, rpmlock_path_default, NULL); if (t == NULL || *t == '\0' || *t == '%') - t = strdup(RPMLOCK_PATH); + t = xstrdup(RPMLOCK_PATH); rpmlock_path = xstrdup(t); t = _free(t); } diff --git a/python/rpmts-py.c b/python/rpmts-py.c index 089953e..244b49a 100644 --- a/python/rpmts-py.c +++ b/python/rpmts-py.c @@ -377,7 +377,7 @@ fprintf(stderr, "*** rpmts_Check(%p) ts %p cb %p\n", s, s->ts, cbInfo.cb); p = rpmpsGetProblem(psi); - byName = strdup(rpmProblemGetPkgNEVR(p)); + byName = xstrdup(rpmProblemGetPkgNEVR(p)); if ((byArch= strrchr(byName, '.')) != NULL) *byArch++ = '\0'; if ((byRelease = strrchr(byName, '-')) != NULL) diff --git a/rpmio/rpmhook.c b/rpmio/rpmhook.c index 8e5f695..6c9b63a 100644 --- a/rpmio/rpmhook.c +++ b/rpmio/rpmhook.c @@ -132,7 +132,7 @@ static void rpmhookTableAddItem(rpmhookTable *table, const char *name, rpmhookBucket bucket = &(*table)->bucket[n]; rpmhookItem *item = &bucket->item; if (!bucket->name) { - bucket->name = strdup(name); + bucket->name = xstrdup(name); (*table)->used++; } while (*item) item = &(*item)->next; -- 2.7.4