mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virNWFilterHashTablePut: Free the correct variable
In bf1fe848
I've introduced 'newName' variable to substitute the old
'const char *name' as previously we had an ugly code there:
name = strdup(name);
However, some parts of the function were not updated, so they were still
calling VIR_FREE(name) instead of VIR_FREE(newName).
This commit is contained in:
parent
4f3729f812
commit
e3d1f6aa7c
@ -647,13 +647,13 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
|
|||||||
int copyName)
|
int copyName)
|
||||||
{
|
{
|
||||||
if (!virHashLookup(table->hashTable, name)) {
|
if (!virHashLookup(table->hashTable, name)) {
|
||||||
|
char *newName;
|
||||||
if (copyName) {
|
if (copyName) {
|
||||||
char *newName;
|
|
||||||
if (VIR_STRDUP(newName, name) < 0)
|
if (VIR_STRDUP(newName, name) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
|
if (VIR_REALLOC_N(table->names, table->nNames + 1) < 0) {
|
||||||
VIR_FREE(name);
|
VIR_FREE(newName);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
table->names[table->nNames++] = newName;
|
table->names[table->nNames++] = newName;
|
||||||
@ -661,7 +661,7 @@ virNWFilterHashTablePut(virNWFilterHashTablePtr table,
|
|||||||
|
|
||||||
if (virHashAddEntry(table->hashTable, name, val) < 0) {
|
if (virHashAddEntry(table->hashTable, name, val) < 0) {
|
||||||
if (copyName) {
|
if (copyName) {
|
||||||
VIR_FREE(name);
|
VIR_FREE(newName);
|
||||||
table->nNames--;
|
table->nNames--;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
|
Loading…
Reference in New Issue
Block a user