summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2012-11-29 14:45:23 +0100
committerMichael Schroeder <mls@suse.de>2012-11-29 14:45:23 +0100
commit936782d2daf5e9396fccdcb6c897ecd6268c9b84 (patch)
tree195385722b8d05cd1a4c62e3d7e64b46095429ad
parent5382a9451f5954c50e49d39fb843bf9eae447ba5 (diff)
downloadlibsolv-936782d2daf5e9396fccdcb6c897ecd6268c9b84.tar.gz
libsolv-936782d2daf5e9396fccdcb6c897ecd6268c9b84.tar.bz2
libsolv-936782d2daf5e9396fccdcb6c897ecd6268c9b84.zip
free tmp repodata when repo_solv returns an error
-rw-r--r--src/repo_solv.c49
1 files changed, 31 insertions, 18 deletions
diff --git a/src/repo_solv.c b/src/repo_solv.c
index 53792fa..62e399f 100644
--- a/src/repo_solv.c
+++ b/src/repo_solv.c
@@ -593,7 +593,10 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
if ((solvflags & SOLV_FLAG_PREFIX_POOL) == 0)
{
if (sizeid && fread(strsp, sizeid, 1, fp) != 1)
- return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
+ {
+ repodata_freedata(&data);
+ return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
+ }
}
else
{
@@ -605,9 +608,10 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
int freesp = sizeid;
if (pfsize && fread(prefix, pfsize, 1, fp) != 1)
- {
+ {
solv_free(prefix);
- return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
+ repodata_freedata(&data);
+ return pool_error(pool, SOLV_ERROR_EOF, "read error while reading strings");
}
for (i = 1; i < numid; i++)
{
@@ -617,6 +621,7 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
if (freesp < 0)
{
solv_free(prefix);
+ repodata_freedata(&data);
return pool_error(pool, SOLV_ERROR_OVERFLOW, "overflow while expanding strings");
}
if (same)
@@ -628,7 +633,10 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
}
solv_free(prefix);
if (freesp != 0)
- return pool_error(pool, SOLV_ERROR_CORRUPT, "expanding strings size mismatch");
+ {
+ repodata_freedata(&data);
+ return pool_error(pool, SOLV_ERROR_CORRUPT, "expanding strings size mismatch");
+ }
}
strsp[sizeid] = 0; /* make string space \0 terminated */
sp = strsp;
@@ -643,12 +651,16 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
if (*sp)
{
/* we need id 1 to be '' for directories */
+ repodata_freedata(&data);
return pool_error(pool, SOLV_ERROR_CORRUPT, "store strings don't start with an empty string");
}
for (i = 1; i < spool->nstrings; i++)
{
if (sp >= strsp + sizeid && numid >= 2)
- return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings");
+ {
+ repodata_freedata(&data);
+ return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings");
+ }
str[i] = sp - spool->stringspace;
sp += strlen(sp) + 1;
}
@@ -700,6 +712,7 @@ repo_add_solv(Repo *repo, FILE *fp, int flags)
spool->nstrings = oldnstrings;
spool->sstrings = oldsstrings;
stringpool_freehash(spool);
+ repodata_freedata(&data);
return pool_error(pool, SOLV_ERROR_OVERFLOW, "not enough strings %d %d", i, numid);
}
if (!*sp) /* empty string */
@@ -1278,6 +1291,7 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
data.incoredata = solv_realloc(data.incoredata, data.incoredatalen);
data.incoredatafree = 0;
}
+ solv_free(idmap);
for (i = 1; i < numkeys; i++)
if (keys[i].storage == KEY_STORAGE_VERTICAL_OFFSET)
@@ -1297,23 +1311,22 @@ printf("=> %s %s %p\n", pool_id2str(pool, keys[key].name), pool_id2str(pool, key
}
data.lastverticaloffset = fileoffset;
pagesize = read_u32(&data);
- data.error = repopagestore_read_or_setup_pages(&data.store, data.fp, pagesize, fileoffset);
- if (data.error == SOLV_ERROR_EOF)
- pool_error(pool, data.error, "repopagestore setup: unexpected EOF");
- else if (data.error)
- pool_error(pool, data.error, "repopagestore setup failed");
- }
- else
- {
- /* no longer needed */
- data.fp = 0;
+ if (!data.error)
+ {
+ data.error = repopagestore_read_or_setup_pages(&data.store, data.fp, pagesize, fileoffset);
+ if (data.error == SOLV_ERROR_EOF)
+ pool_error(pool, data.error, "repopagestore setup: unexpected EOF");
+ else if (data.error)
+ pool_error(pool, data.error, "repopagestore setup failed");
+ }
}
- solv_free(idmap);
+ data.fp = 0; /* no longer needed */
if (data.error)
{
- /* XXX: free repodata? */
- return data.error;
+ i = data.error;
+ repodata_freedata(&data);
+ return i;
}
if (parent)