diff options
-rw-r--r-- | src/variable.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/variable.c b/src/variable.c index e6bad1a..6b23c00 100644 --- a/src/variable.c +++ b/src/variable.c @@ -1,27 +1,27 @@ -/* This file is part of vmod-tbf - Copyright (C) 2013-2015 Sergey Poznyakoff +/* This file is part of vmod-variable + Copyright (C) 2013-2016 Sergey Poznyakoff - Vmod-tbf is free software; you can redistribute it and/or modify + Vmod-variable is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. - Vmod-tbf is distributed in the hope that it will be useful, + Vmod-variable is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with vmod-tbf. If not, see <http://www.gnu.org/licenses/>. + along with vmod-variable. If not, see <http://www.gnu.org/licenses/>. */ #include <config.h> #include <stdlib.h> #include <stdarg.h> #include <syslog.h> #include <ctype.h> #include <pcre.h> #include "vrt.h" #include "vcc_if.h" #include "pthread.h" #if VARNISHVERSION == 3 # include "bin/varnishd/cache.h" @@ -173,24 +173,27 @@ symtab_remove(struct symtab *st, const char *name) struct variable *entry; pos = hash_string(name, hash_size[st->hash_num]); for (i = pos; (entry = st->tab[i]);) { if (strcmp(entry->name, name) == 0) break; if (++i >= hash_size[st->hash_num]) i = 0; if (i == pos) return ENOENT; } + if (!entry) + return ENOENT; + var_free(entry); for (;;) { st->tab[i] = NULL; j = i; do { if (++i >= hash_size[st->hash_num]) i = 0; if (!st->tab[i]) return 0; r = hash_string(st->tab[i]->name, hash_size[st->hash_num]); @@ -383,24 +386,25 @@ vmod_global_unset(VARIABLE_CTX ctx, VCL_STRING name) static struct symtab * get_symtab(VARIABLE_CTX ctx) { struct symtab *st; int fd = ctx->req->sp->fd; assert(fd >= 0); AZ(pthread_mutex_lock(&symtab_mtx)); if (symtabc <= fd) { size_t n = fd + 1; symtabv = realloc(symtabv, n * sizeof(symtabv[0])); + AN(symtabv); while (symtabc < n) symtabv[symtabc++] = NULL; } if (!symtabv[fd]) symtabv[fd] = symtab_create(); st = symtabv[fd]; if (st->vxid != ctx->req->sp->vxid) symtab_clear(st); st->vxid = ctx->req->sp->vxid; AZ(pthread_mutex_unlock(&symtab_mtx)); return st; } |