Paul Gofman : hnetcfg: Handle NULL strings in update_mapping_list().
Alexandre Julliard
julliard at winehq.org
Thu Feb 3 16:06:57 CST 2022
Module: wine
Branch: master
Commit: 31f0509b72e2bfdef83c313e0dd41374f4fb6828
URL: https://source.winehq.org/git/wine.git/?a=commit;h=31f0509b72e2bfdef83c313e0dd41374f4fb6828
Author: Paul Gofman <pgofman at codeweavers.com>
Date: Thu Feb 3 14:28:32 2022 +0300
hnetcfg: Handle NULL strings in update_mapping_list().
Signed-off-by: Paul Gofman <pgofman at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/hnetcfg/port.c | 31 ++++++++++++++++++++++---------
1 file changed, 22 insertions(+), 9 deletions(-)
diff --git a/dlls/hnetcfg/port.c b/dlls/hnetcfg/port.c
index 611a652ce5e..47bfc16be79 100644
--- a/dlls/hnetcfg/port.c
+++ b/dlls/hnetcfg/port.c
@@ -540,6 +540,22 @@ static LONG long_from_bstr( BSTR s )
return _wtoi( s );
}
+static BSTR mapping_move_bstr( BSTR *s )
+{
+ BSTR ret;
+
+ if (*s)
+ {
+ ret = *s;
+ *s = NULL;
+ }
+ else if (!(ret = SysAllocString( L"" )))
+ {
+ ERR( "No memory.\n" );
+ }
+ return ret;
+}
+
static void update_mapping_list(void)
{
struct xml_value_desc mapping_desc[ARRAY_SIZE(port_mapping_template)];
@@ -579,20 +595,17 @@ static void update_mapping_list(void)
}
break;
}
- new_mappings[index].external_ip = mapping_desc[PM_EXTERNAL_IP].value;
- mapping_desc[PM_EXTERNAL_IP].value = NULL;
+ new_mappings[index].external_ip = mapping_move_bstr( &mapping_desc[PM_EXTERNAL_IP].value );
new_mappings[index].external = long_from_bstr( mapping_desc[PM_EXTERNAL].value );
- new_mappings[index].protocol = mapping_desc[PM_PROTOCOL].value;
- mapping_desc[PM_PROTOCOL].value = NULL;
+ new_mappings[index].protocol = mapping_move_bstr( &mapping_desc[PM_PROTOCOL].value );
new_mappings[index].internal = long_from_bstr( mapping_desc[PM_INTERNAL].value );
- new_mappings[index].client = mapping_desc[PM_CLIENT].value;
- mapping_desc[PM_CLIENT].value = NULL;
- if (!wcsicmp( mapping_desc[PM_ENABLED].value, L"true" ) || long_from_bstr( mapping_desc[PM_ENABLED].value ))
+ new_mappings[index].client = mapping_move_bstr( &mapping_desc[PM_CLIENT].value );
+ if (mapping_desc[PM_ENABLED].value && (!wcsicmp( mapping_desc[PM_ENABLED].value, L"true" )
+ || long_from_bstr( mapping_desc[PM_ENABLED].value )))
new_mappings[index].enabled = VARIANT_TRUE;
else
new_mappings[index].enabled = VARIANT_FALSE;
- new_mappings[index].descr = mapping_desc[PM_DESC].value;
- mapping_desc[PM_DESC].value = NULL;
+ new_mappings[index].descr = mapping_move_bstr( &mapping_desc[PM_DESC].value );
TRACE( "%s %s %s:%u -> %s:%u, enabled %d.\n", debugstr_w(new_mappings[index].descr),
debugstr_w(new_mappings[index].protocol), debugstr_w(new_mappings[index].external_ip),
More information about the wine-cvs
mailing list