Patch to context_new to set errno to EINVAL on bad values

Signed-off-by: Joshua Brindle <method@manicmethod.com>
This commit is contained in:
Daniel J Walsh 2010-03-24 09:17:03 -04:00 committed by Joshua Brindle
parent d57ea2c2c0
commit 7dcf27a791
1 changed files with 2 additions and 0 deletions

View File

@ -22,6 +22,7 @@ typedef struct {
context_t context_new(const char *str) context_t context_new(const char *str)
{ {
int i, count; int i, count;
errno = 0;
context_private_t *n = context_private_t *n =
(context_private_t *) malloc(sizeof(context_private_t)); (context_private_t *) malloc(sizeof(context_private_t));
context_t result = (context_t) malloc(sizeof(context_s_t)); context_t result = (context_t) malloc(sizeof(context_s_t));
@ -76,6 +77,7 @@ context_t context_new(const char *str)
} }
return result; return result;
err: err:
if (errno == 0) errno = EINVAL;
context_free(result); context_free(result);
return 0; return 0;
} }