]> granicus.if.org Git - mutt/commitdiff
check_charset: check for NULL before calling strtok_r (closes #3326)
authorAntonio Radici <antonio@dyne.org>
Sun, 8 Jul 2012 04:57:01 +0000 (21:57 -0700)
committerAntonio Radici <antonio@dyne.org>
Sun, 8 Jul 2012 04:57:01 +0000 (21:57 -0700)
Otherwise, if strtok_r cannot handle NULL an empty *charset setting will segfault

init.c

diff --git a/init.c b/init.c
index efdba2dbb1f907e802963a3354b2c463bf2bdb52..910c6cf96c162bffea146d2653c993f3af136b47 100644 (file)
--- 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)