[PATCH 1/4] Check for null pointers before strcmp. (LLVM/Clang)
Lauri Kenttä
lauri.kentta at gmail.com
Fri Jun 10 15:38:37 CDT 2011
---
dlls/ws2_32/tests/sock.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c
index 28d5db3..1c07802 100644
--- a/dlls/ws2_32/tests/sock.c
+++ b/dlls/ws2_32/tests/sock.c
@@ -2801,13 +2801,13 @@ static void test_addr_to_print(void)
pdst = inet_ntoa(*((struct in_addr*)&in.s_addr));
ok(pdst != NULL, "inet_ntoa failed %s\n", dst);
- ok(!strcmp(pdst, addr0_Str),"Address %s != %s\n", pdst, addr0_Str);
+ ok(pdst && !strcmp(pdst, addr0_Str),"Address %s != %s\n", pdst, addr0_Str);
/* Test that inet_ntoa and inet_ntop return the same value */
in.S_un.S_addr = addr1_Num;
pdst = inet_ntoa(*((struct in_addr*)&in.s_addr));
ok(pdst != NULL, "inet_ntoa failed %s\n", dst);
- ok(!strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
+ ok(pdst && !strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
/* InetNtop became available in Vista and Win2008 */
if (!pInetNtop)
@@ -2819,7 +2819,7 @@ static void test_addr_to_print(void)
/* Second part of test */
pdst = pInetNtop(AF_INET,(void*)&in.s_addr, dst, sizeof(dst));
ok(pdst != NULL, "InetNtop failed %s\n", dst);
- ok(!strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
+ ok(pdst && !strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
/* Test invalid parm conditions */
pdst = pInetNtop(1, (void*)&in.s_addr, dst, sizeof(dst));
@@ -2854,7 +2854,7 @@ static void test_addr_to_print(void)
pdst = NULL;
pdst = pInetNtop(AF_INET, (void*)&in.s_addr, dst, sizeof(dst)+1);
ok(pdst != NULL, "The pointer should be returned (%p)\n", pdst);
- ok(!strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
+ ok(pdst && !strcmp(pdst, addr1_Str),"Address %s != %s\n", pdst, addr1_Str);
/* Test the IPv6 addresses */
@@ -2862,19 +2862,19 @@ static void test_addr_to_print(void)
memcpy(in6.u.Byte, addr2_Num, sizeof(addr2_Num));
pdst = pInetNtop(AF_INET6,(void*)&in6.s6_addr, dst6, sizeof(dst6));
ok(pdst != NULL, "InetNtop failed %s\n", dst6);
- ok(!strcmp(pdst, addr2_Str),"Address %s != %s\n", pdst, addr2_Str);
+ ok(pdst && !strcmp(pdst, addr2_Str),"Address %s != %s\n", pdst, addr2_Str);
/* Test an zero suffixed IPV6 address */
memcpy(in6.s6_addr, addr3_Num, sizeof(addr3_Num));
pdst = pInetNtop(AF_INET6,(void*)&in6.s6_addr, dst6, sizeof(dst6));
ok(pdst != NULL, "InetNtop failed %s\n", dst6);
- ok(!strcmp(pdst, addr3_Str),"Address %s != %s\n", pdst, addr3_Str);
+ ok(pdst && !strcmp(pdst, addr3_Str),"Address %s != %s\n", pdst, addr3_Str);
/* Test the IPv6 address contains the IPv4 address in IPv4 notation */
memcpy(in6.s6_addr, addr4_Num, sizeof(addr4_Num));
pdst = pInetNtop(AF_INET6, (void*)&in6.s6_addr, dst6, sizeof(dst6));
ok(pdst != NULL, "InetNtop failed %s\n", dst6);
- ok(!strcmp(pdst, addr4_Str),"Address %s != %s\n", pdst, addr4_Str);
+ ok(pdst && !strcmp(pdst, addr4_Str),"Address %s != %s\n", pdst, addr4_Str);
/* Test invalid parm conditions */
memcpy(in6.u.Byte, addr2_Num, sizeof(addr2_Num));
--
1.7.5.2
More information about the wine-patches
mailing list