fix rpmlib 4.0.x segfault that is a result of iterator freeing after the creating...
authorcturner <devnull@localhost>
Sun, 16 Mar 2003 23:31:08 +0000 (23:31 +0000)
committercturner <devnull@localhost>
Sun, 16 Mar 2003 23:31:08 +0000 (23:31 +0000)
CVS patchset: 6696
CVS date: 2003/03/16 23:31:08

perl-RPM2/RPM2.pm

index 05f217d..d38b389 100644 (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;