Mercurial > hg > th-libs
changeset 110:d739df7efba7
Use dynamic allocation for one buffer.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 21 Jun 2014 21:12:27 +0300 |
parents | fedad0ed894f |
children | cddfc43a4e45 |
files | th_config.c |
diffstat | 1 files changed, 8 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/th_config.c Sat Jun 21 20:42:06 2014 +0300 +++ b/th_config.c Sat Jun 21 21:12:27 2014 +0300 @@ -221,7 +221,7 @@ static int th_cfg_read_sect(th_ioctx_t *ctx, th_cfgitem_t *cfg, int nesting) { th_cfgitem_t *item = NULL; - char tmpStr[SET_MAX_BUF + 1]; + char *tmpStr = NULL; size_t strPos; int c, parseMode, prevMode, nextMode, tmpCh; BOOL isFound, isStart, isError, validError; @@ -233,6 +233,9 @@ isFound = isStart = isError = validError = FALSE; nextMode = prevMode = parseMode = PM_NORMAL; + if ((tmpStr = th_malloc(SET_MAX_BUF + 1)) == NULL) + goto out; + /* Parse the configuration */ while (parseMode != PM_EOF && parseMode != PM_ERROR) { @@ -284,10 +287,8 @@ else if (c == '}') { if (nesting > 0) - { /* Check for validation errors */ - return (validError) ? 1 : 0; - } + goto out; else { th_ioctx_error(ctx, -1, @@ -665,6 +666,9 @@ } } +out: + th_free(tmpStr); + /* Check for validation errors */ if (validError) return 1;