diff options
author | Jeremy Huddleston <jeremyhu@apple.com> | 2011-05-06 23:12:50 -0700 |
---|---|---|
committer | Jeremy Huddleston <jeremyhu@apple.com> | 2011-05-06 23:12:50 -0700 |
commit | 5032c286df16737277c9a04e1083171ffec89000 (patch) | |
tree | 892c586d51d1fbe0158312988b8cd75fae7dc711 | |
parent | 9197410a2b5c875885266713f5dc470b6dac476b (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.c | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -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 */ |