From 215178323034e25186f40d0e059942ec11e05eef Mon Sep 17 00:00:00 2001 From: Antonio Radici Date: Sat, 7 Jul 2012 21:57:01 -0700 Subject: [PATCH] check_charset: check for NULL before calling strtok_r (closes #3326) Otherwise, if strtok_r cannot handle NULL an empty *charset setting will segfault --- init.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.c b/init.c index efdba2db..910c6cf9 100644 --- a/init.c +++ b/init.c @@ -1672,6 +1672,9 @@ static int check_charset (struct option_t *opt, const char *val) char *p, *q = NULL, *s = safe_strdup (val); int rc = 0, strict = strcmp (opt->option, "send_charset") == 0; + if (!s) + return rc; + for (p = strtok_r (s, ":", &q); p; p = strtok_r (NULL, ":", &q)) { if (!*p) -- 2.40.0