From ff77b396197ae9d4891831efda4d3a0c7f71b6e4 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Fri, 13 Feb 2015 13:39:16 +0200 Subject: Bugfixes * src/variable.c (vmod_defined): Fix return type. (vmod_regset): Fix ovsize calculation. * src/variable.vcc (defined): Fix return type. --- src/variable.c | 15 ++++++++------- src/variable.vcc | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/variable.c b/src/variable.c index 5deda1b..4dbfba5 100644 --- a/src/variable.c +++ b/src/variable.c @@ -383,7 +383,7 @@ get_symtab(VARIABLE_CTX ctx) #define getvar(vt, name) symtab_lookup_or_install(vt, name, NULL) -struct variable * +static struct variable * defvar(struct symtab *vt, const char *name, enum variable_type t, union value *val) { @@ -466,7 +466,7 @@ DEF(int, VCL_INT, i) DEF(real, VCL_REAL, r) DEF(duration, VCL_DURATION, d) -VCL_INT +VCL_BOOL vmod_defined(VARIABLE_CTX ctx, VCL_STRING name) { return !!getvar(get_symtab(ctx), name); @@ -485,7 +485,7 @@ vmod_undef(VARIABLE_CTX ctx, VCL_STRING name) symtab_remove(get_symtab(ctx), name); } -void +static void log_error(const char *fmt, ...) { va_list ap; @@ -601,7 +601,7 @@ str2duration(const char *str) return *p ? 0 : r; } -char * +static char * bref_expand(const char *str, const char *input, pcre *re, int ovsize, int *ovector) { @@ -783,12 +783,13 @@ vmod_regset(VARIABLE_CTX ctx, VCL_STRING vars, VCL_STRING rxs, rxs, vars); vardef_free(head); return; - } - - ovsize = (count + 1) * 3; + } + + ovsize = (n + 1) * 3; ovector = calloc(ovsize, sizeof(*ovector)); rc = pcre_exec(re, 0, input, strlen(input), 0, 0, ovector, ovsize); + if (rc <= 0) { if (rc != PCRE_ERROR_NOMATCH) log_error("variable.regset: pcre_exec failed: %d", rc); diff --git a/src/variable.vcc b/src/variable.vcc index f0106e9..9bf8f46 100644 --- a/src/variable.vcc +++ b/src/variable.vcc @@ -30,7 +30,7 @@ $Function VOID set_duration(STRING, DURATION) $Function DURATION get_duration(STRING) $Function VOID clear() -$Function INT defined(STRING) +$Function BOOL defined(STRING) $Function STRING type_of(STRING) $Function VOID undef(STRING) $Function VOID regset(STRING, STRING, STRING) -- cgit v1.2.1