Mercurial > hg > th-libs
comparison th_regex.c @ 721:c834e1393eb0
Initialize regex parsing context before checking pointers.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sun, 13 Dec 2020 13:53:06 +0200 |
parents | 838189b856f3 |
children | 4ca6a3b30fe8 |
comparison
equal
deleted
inserted
replaced
720:ff724f45162a | 721:c834e1393eb0 |
---|---|
455 th_regex_parse_ctx_t ctx; | 455 th_regex_parse_ctx_t ctx; |
456 th_regex_node_t node, *pnode; | 456 th_regex_node_t node, *pnode; |
457 th_char_t *tmp = NULL; | 457 th_char_t *tmp = NULL; |
458 size_t start; | 458 size_t start; |
459 | 459 |
460 memset(&ctx, 0, sizeof(ctx)); | |
461 | |
460 // Check pointers | 462 // Check pointers |
461 if (pexpr == NULL || pattern == NULL) | 463 if (pexpr == NULL || pattern == NULL) |
462 { | 464 { |
463 res = THERR_NULLPTR; | 465 res = THERR_NULLPTR; |
464 goto out; | 466 goto out; |
465 } | 467 } |
466 | 468 |
467 // Initialize parsing context | 469 // Initialize parsing context |
468 memset(&ctx, 0, sizeof(ctx)); | |
469 ctx.pattern = pattern; | 470 ctx.pattern = pattern; |
470 ctx.bufSize = 256; | 471 ctx.bufSize = 256; |
471 | 472 |
472 if ((ctx.buf = th_malloc(ctx.bufSize * sizeof(th_char_t))) == NULL) | 473 if ((ctx.buf = th_malloc(ctx.bufSize * sizeof(th_char_t))) == NULL) |
473 { | 474 { |