summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Huddleston <jeremyhu@apple.com>2011-05-06 23:12:50 -0700
committerJeremy Huddleston <jeremyhu@apple.com>2011-05-06 23:12:50 -0700
commit5032c286df16737277c9a04e1083171ffec89000 (patch)
tree892c586d51d1fbe0158312988b8cd75fae7dc711
parent9197410a2b5c875885266713f5dc470b6dac476b (diff)
Error out and avoid a call to malloc(0) if given a bad hex string
process.c:567:14: warning: Call to 'malloc' has an allocation size of 0 bytes retval = malloc (len); ^ ~~~ 1 warning generated. Found-by: clang static analyzer Signed-off-by: Jeremy Huddleston <jeremyhu@apple.com>
-rw-r--r--process.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/process.c b/process.c
index ee761e2..04abc33 100644
--- a/process.c
+++ b/process.c
@@ -558,8 +558,8 @@ cvthexkey(char *hexstr, char **ptrp) /* turn hex key string into octets */
len++;
}
- /* if odd then there was an error */
- if ((len & 1) == 1) return -1;
+ /* if 0 or odd, then there was an error */
+ if (len == 0 || (len & 1) == 1) return -1;
/* now we know that the input is good */