Re: [PATCH] Fix the function that remove the element of the hash table.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 29, 2008 at 11:32:04AM +0900, Hiroyuki Kaguchi wrote:
> There are two logic error and a unnecessary else-statement
> in virHashRemoveSet function.
> 
> This patch fix the following.
> (1/3) The logic error that use released memory area.
> (2/3) The logic error that doesn't remove elements.
> (3/3) Unnecessary else-statement.


> Index: hash.c
> ===================================================================
> RCS file: /data/cvs/libvirt/src/hash.c,v
> retrieving revision 1.27
> diff -u -r1.27 hash.c
> --- hash.c	21 Jan 2008 16:29:10 -0000	1.27
> +++ hash.c	28 Jan 2008 06:48:09 -0000
> @@ -543,6 +543,7 @@
>                  if (prev) {
>                      prev->next = entry->next;
>                      free(entry);
> +                    entry = prev;
>                  } else {
>                      if (entry->next == NULL) {
>                          entry->valid = 0;

ACK, this is definitely needed.

> @@ -553,6 +554,7 @@
>                                 sizeof(virHashEntry));
>                          free(entry);
>                          entry = NULL;
> +                        i--;
>                      }
>                  }
>                  table->nbElems--;

I'm still not 100% clear on the logic around here, but I
think your suggestion is correct.

> @@ -560,8 +562,6 @@
>              prev = entry;
>              if (entry) {
>                  entry = entry->next;
> -            } else {
> -                entry = NULL;
>              }
>          }
>      }

ACK, clearly correct.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]