Fixed problem with how delete on an undef value was working
rkinyon [Wed, 20 Dec 2006 05:54:05 +0000 (05:54 +0000)]
lib/DBM/Deep/Engine3.pm

index b1a5f33..15a8022 100644 (file)
@@ -1039,7 +1039,7 @@ sub delete_key {
     my $location = $blist->get_data_location_for({
         allow_head => 0,
     });
-    my $old_value = $self->engine->_load_sector( $location );
+    my $old_value = $location && $self->engine->_load_sector( $location );
 
     if ( $self->engine->trans_id == 0 ) {
         my @transactions = $self->engine->read_transaction_slots;
@@ -1059,8 +1059,11 @@ sub delete_key {
 
     $blist->mark_deleted( $args );
 
-    my $data = $old_value->data;
-    $old_value->free;
+    my $data;
+    if ( $old_value ) {
+        $data = $old_value->data;
+        $old_value->free;
+    }
 
     return $data;
 }