*** /usr/bin/durep.dpkg-dist    2009-01-25 15:23:23.000000000 +0100
--- /usr/bin/durep      2009-01-25 15:24:56.000000000 +0100
***************
*** 175,180 ****
--- 175,181 ----
    my $coalesced_size = 0;
    my $node = {};
    my $temp;
+   my $dirhandle;

    $node->{ID} = $next_id++;
    if(defined $parent) {
***************
*** 196,204 ****

    $node->{TYPE} &= $TYPE_COLLAPSED unless $store;

!   opendir(DIR, $dir) or warn "Unable to open dir '$dir': $!\n" and return $node;

!   foreach(readdir(DIR)) {
      @stats = lstat "$dir/$_" or warn "Unable to lstat '$dir/$_': $!\n" and next;

      $node->{MTIME} = $stats[9] if($_ eq ".");
--- 197,205 ----

    $node->{TYPE} &= $TYPE_COLLAPSED unless $store;

!   opendir($dirhandle, $dir) or warn "Unable to open dir '$dir': $!\n" and return $node;

!   foreach(readdir($dirhandle)) {
      @stats = lstat "$dir/$_" or warn "Unable to lstat '$dir/$_': $!\n" and next;

      $node->{MTIME} = $stats[9] if($_ eq ".");
***************
*** 247,253 ****
      $file_count++;
      $node->{FCOUNT}++;
    }
!   closedir(DIR);

    if($coalesced_count) {
      if($store) {
--- 248,254 ----
      $file_count++;
      $node->{FCOUNT}++;
    }
!   closedir($dirhandle);

    if($coalesced_count) {
      if($store) {

