diff options
author | Yunlian Jiang <yunlian@google.com> | 2017-02-07 15:39:25 -0800 |
---|---|---|
committer | Stephen Hines <srhines@google.com> | 2017-02-08 16:47:20 -0800 |
commit | 33f671782a1985b02e4410b923e9688ffd3c1e71 (patch) | |
tree | 058d87c1df35d2eb545450dad1158b30968b3421 | |
parent | 23f4e6b0a5ce3eee548a4cd9e857f522ddaf492b (diff) | |
download | system_core-33f671782a1985b02e4410b923e9688ffd3c1e71.tar.gz system_core-33f671782a1985b02e4410b923e9688ffd3c1e71.tar.bz2 system_core-33f671782a1985b02e4410b923e9688ffd3c1e71.zip |
fix warning: Null pointer argument in call to memory comparison function
This fixes warning: Null pointer argument in call to
memory comparison function [clang-analyzer-cplusplus.NewDeleteLeaks]
Bug: None
Test: The warning is gone.
Change-Id: I957365184966cc1435d7e37d64f2cc6a32846ebd
-rw-r--r-- | libsysutils/src/NetlinkEvent.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libsysutils/src/NetlinkEvent.cpp b/libsysutils/src/NetlinkEvent.cpp index fef801ad0..79bc88853 100644 --- a/libsysutils/src/NetlinkEvent.cpp +++ b/libsysutils/src/NetlinkEvent.cpp @@ -561,10 +561,12 @@ bool NetlinkEvent::parseBinaryNetlinkMessage(char *buffer, int size) { static const char* has_prefix(const char* str, const char* end, const char* prefix, size_t prefixlen) { - if ((end-str) >= (ptrdiff_t)prefixlen && !memcmp(str, prefix, prefixlen)) + if ((end - str) >= (ptrdiff_t)prefixlen && + (prefixlen == 0 || !memcmp(str, prefix, prefixlen))) { return str + prefixlen; - else + } else { return NULL; + } } /* Same as strlen(x) for constant string literals ONLY */ |