From 296e4d08e79816ef1474596e81857b9261500f22 Mon Sep 17 00:00:00 2001 From: Pekka Riikonen Date: Sun, 21 Sep 2008 15:32:04 +0300 Subject: [PATCH] SilcRegex: Fixed silc_regex to return correct value for optional args In grouped expressions, optional, non-matched arguments didn't have their value set to NULL as documented. Set all arguments by default to NULL. --- lib/silcutil/silcregex.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/silcutil/silcregex.c b/lib/silcutil/silcregex.c index 84449695..3c83ed78 100644 --- a/lib/silcutil/silcregex.c +++ b/lib/silcutil/silcregex.c @@ -2411,6 +2411,7 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, silc_regex_free(®); return FALSE; } + silc_buffer_set(match, NULL, 0); rets[c++] = match; while ((buf = va_arg(va, SilcBuffer))) { @@ -2421,6 +2422,7 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, silc_regex_free(®); return FALSE; } + silc_buffer_set(buf, NULL, 0); rets[c++] = buf; } @@ -2444,10 +2446,8 @@ SilcBool silc_regex_va(const char *string, SilcUInt32 string_len, /* Return matches */ for (i = 0; i < c; i++) { - if (m[i].start == -1) { - silc_buffer_set(rets[i], NULL, 0); + if (m[i].start == -1) continue; - } silc_buffer_set(rets[i], (unsigned char *)string + m[i].start, m[i].end - m[i].start); } -- 2.24.0