summaryrefslogtreecommitdiff
path: root/src/repo.h
diff options
context:
space:
mode:
authorMichael Schroeder <mls@suse.de>2009-06-30 12:15:48 +0200
committerMichael Schroeder <mls@suse.de>2009-06-30 12:15:48 +0200
commit6e69cc27d20604d6c48621772c37e40e76f7a3ad (patch)
tree9fe3aec1a66472e2327d658ab24490c78d32e576 /src/repo.h
parentf82518d71959fe6df38467b1ca96d5f91b8a6139 (diff)
downloadlibsolv-6e69cc27d20604d6c48621772c37e40e76f7a3ad.tar.gz
libsolv-6e69cc27d20604d6c48621772c37e40e76f7a3ad.tar.bz2
libsolv-6e69cc27d20604d6c48621772c37e40e76f7a3ad.zip
- fix sidedata segfault
Diffstat (limited to 'src/repo.h')
-rw-r--r--src/repo.h34
1 files changed, 12 insertions, 22 deletions
diff --git a/src/repo.h b/src/repo.h
index b5329e9..bb6eabd 100644
--- a/src/repo.h
+++ b/src/repo.h
@@ -65,19 +65,14 @@ static inline Id repo_add_solvable(Repo *repo)
extern Id pool_add_solvable(Pool *pool);
Id p = pool_add_solvable(repo->pool);
if (!repo->start || repo->start == repo->end)
- {
- repo->start = p;
- repo->end = p + 1;
- }
- else
- {
- if (p < repo->start)
- repo->start = p;
- if (p + 1 > repo->end)
- repo->end = p + 1;
- }
+ repo->start = repo->end = p;
+ /* warning: sidedata must be extended before adapting start/end */
if (repo->rpmdbid)
repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, 1);
+ if (p < repo->start)
+ repo->start = p;
+ if (p + 1 > repo->end)
+ repo->end = p + 1;
repo->nsolvables++;
repo->pool->solvables[p].repo = repo;
return p;
@@ -92,19 +87,14 @@ static inline Id repo_add_solvable_block(Repo *repo, int count)
return 0;
p = pool_add_solvable_block(repo->pool, count);
if (!repo->start || repo->start == repo->end)
- {
- repo->start = p;
- repo->end = p + count;
- }
- else
- {
- if (p < repo->start)
- repo->start = p;
- if (p + count > repo->end)
- repo->end = p + count;
- }
+ repo->start = repo->end = p;
+ /* warning: sidedata must be extended before adapting start/end */
if (repo->rpmdbid)
repo->rpmdbid = (Id *)repo_sidedata_extend(repo, repo->rpmdbid, sizeof(Id), p, count);
+ if (p < repo->start)
+ repo->start = p;
+ if (p + count > repo->end)
+ repo->end = p + count;
repo->nsolvables += count;
for (s = repo->pool->solvables + p; count--; s++)
s->repo = repo;