From 84f95447a3eb7ab79f6d820d3f96ddf5bd4d05aa Mon Sep 17 00:00:00 2001 From: Ilya Shipitsin Date: Fri, 29 Apr 2016 23:59:35 +0500 Subject: [PATCH] cppcheck issues: [src/Cedar/WebUI.c:1728] -> [src/Cedar/WebUI.c:1730]: (warning) Either the condition 'buf==0' is redundant or there is possible null pointer dereference: buf. [src/Mayaqua/FileIO.c:383] -> [src/Mayaqua/FileIO.c:386]: (warning) Either the condition 'p==0' is redundant or there is possible null pointer dereference: p. [src/Mayaqua/TcpIp.c:1837] -> [src/Mayaqua/TcpIp.c:1839]: (warning) Either the condition 'tcp!=0' is redundant or there is possible null pointer dereference: tcp. --- src/Cedar/WebUI.c | 2 +- src/Mayaqua/FileIO.c | 2 +- src/Mayaqua/TcpIp.c | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Cedar/WebUI.c b/src/Cedar/WebUI.c index e488835f..f71c385f 100644 --- a/src/Cedar/WebUI.c +++ b/src/Cedar/WebUI.c @@ -1725,12 +1725,12 @@ static wchar_t *WuUniReadFile(char *filename) static void WuUniReplace(wchar_t **buf, wchar_t *from, wchar_t *to) { UINT dstsize; - wchar_t *oldbuf = *buf; if(buf == NULL || from == NULL || to == NULL) { return; } + wchar_t *oldbuf = *buf; dstsize = (UniCalcReplaceStrEx(*buf, from, to, true) + 1) * sizeof(wchar_t); *buf = (wchar_t*)Malloc(dstsize); diff --git a/src/Mayaqua/FileIO.c b/src/Mayaqua/FileIO.c index 49fbec95..02abafb0 100644 --- a/src/Mayaqua/FileIO.c +++ b/src/Mayaqua/FileIO.c @@ -380,13 +380,13 @@ void ZipAddFileStart(ZIP_PACKER *p, char *name, UINT size, UINT64 dt, UINT attri // Add data to the file UINT ZipAddFileData(ZIP_PACKER *p, void *data, UINT pos, UINT len) { - UINT total_size = p->CurrentFile->CurrentSize + len; UINT ret; // Validate arguments if (p == NULL) { return 0; } + UINT total_size = p->CurrentFile->CurrentSize + len; if (total_size > p->CurrentFile->Size) { return 0; diff --git a/src/Mayaqua/TcpIp.c b/src/Mayaqua/TcpIp.c index 39c43c09..5bed26a7 100644 --- a/src/Mayaqua/TcpIp.c +++ b/src/Mayaqua/TcpIp.c @@ -1834,9 +1834,9 @@ PKT *ParsePacketEx4(UCHAR *buf, UINT size, bool no_l3, UINT vlan_type_id, bool b if ((p->TypeL3 == L3_IPV4 || p->TypeL3 == L3_IPV6) && p->TypeL4 == L4_TCP) { TCP_HEADER *tcp = p->L4.TCPHeader; - if (tcp->DstPort == port_raw || tcp->DstPort == port_raw2) + if (tcp != NULL && (!((tcp->Flag & TCP_SYN) || (tcp->Flag & TCP_RST) || (tcp->Flag & TCP_FIN)))) { - if (tcp != NULL && (!((tcp->Flag & TCP_SYN) || (tcp->Flag & TCP_RST) || (tcp->Flag & TCP_FIN)))) + if (tcp->DstPort == port_raw || tcp->DstPort == port_raw2) { if (p->PayloadSize >= 1) {