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
This commit is contained in:
parent
23f4e6b0a5
commit
33f671782a
1 changed files with 4 additions and 2 deletions
|
@ -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 */
|
||||
|
|
Loading…
Reference in a new issue