From: Panu Matilainen Date: Wed, 16 Sep 2009 09:27:12 +0000 (+0300) Subject: One complicated way to write xstrdup() .. pff X-Git-Tag: rpm-4.8.0-beta1~279 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=90a0f752808d166e7d1640d60cd3a7d4cd26154e;p=platform%2Fupstream%2Frpm.git One complicated way to write xstrdup() .. pff - sqlite backend uses dbi subfile for table name, leave it alone although it is the same as the file name... - allocate + free both file and table name separately --- diff --git a/lib/backend/sqlite.c b/lib/backend/sqlite.c index 4c1262c..a47c569 100644 --- a/lib/backend/sqlite.c +++ b/lib/backend/sqlite.c @@ -772,6 +772,7 @@ enterChroot(dbi); dbi->dbi_stats = _free(dbi->dbi_stats); dbi->dbi_file = _free(dbi->dbi_file); + dbi->dbi_subfile = _free(dbi->dbi_subfile); dbi->dbi_db = _free(dbi->dbi_db); leaveChroot(dbi); @@ -801,7 +802,6 @@ static int sql_open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip) const char * sql_errcode; dbiIndex dbi; SQL_DB * sqldb; - size_t len; int rc = 0; int xx; @@ -831,15 +831,8 @@ enterChroot(dbi); * Make a copy of the tagName result.. * use this for the filename and table name */ - { - char * t; - len = strlen(dbfile); - t = xcalloc(len + 1, sizeof(*t)); - (void) stpcpy( t, dbfile ); - dbi->dbi_file = t; -/* WRONG */ - dbi->dbi_subfile = t; - } + dbi->dbi_file = xstrdup(dbfile); + dbi->dbi_subfile = xstrdup(dbfile); dbi->dbi_mode=O_RDWR;