fix rpmlib 4.0.x segfault that is a result of iterator freeing after the creating db is freed

CVS patchset: 6696
CVS date: 2003/03/16 23:31:08
This commit is contained in:
cturner 2003-03-16 23:31:08 +00:00
parent cfa8f19149
commit 423aba69ef
1 changed files with 9 additions and 1 deletions

View File

@ -273,7 +273,7 @@ sub new_iterator {
my $tag = shift;
my $key = shift;
my $self = bless { }, $class;
my $self = bless { db => $db }, $class;
$self->{c_iter} = RPM2::C::DB::_init_iterator($db->{c_db},
$RPM2::header_tag_map{$tag},
$key || "",
@ -303,6 +303,14 @@ sub expand_iter {
return @ret;
}
# make sure c_iter is destroyed before {db} so that we always free an
# iterator before we free the db it came from
sub DESTROY {
my $self = shift;
delete $self->{c_iter};
}
# Preloaded methods go here.
1;