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]

 



Though this patch has not been applied yet, are there any problems in this patch?
If there is no problem, could you apply this patch ?

(2008/01/29 23:45), Daniel P. Berrange wrote:
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.


--
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]