[Libvir] [PATCH] Fix the function that remove the element of the hash table.
Hiroyuki Kaguchi
fj7025cf at aa.jp.fujitsu.com
Wed Feb 6 08:17:07 UTC 2008
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.
More information about the libvir-list
mailing list