diff -urN poldek-0.30-cvs20080820.23/misc.c poldek-0.30-cvs20080820.23.new/misc.c --- poldek-0.30-cvs20080820.23/misc.c 2008-07-19 11:52:31.000000000 +0200 +++ poldek-0.30-cvs20080820.23.new/misc.c 2008-11-23 15:54:42.835970687 +0100 @@ -626,7 +626,7 @@ */ static char *cut_country_code (const char *lang) { - char *p, *q, *newlang; + char *c, *p, *q, *newlang; if ((q = strchr(lang, '_')) == NULL) return NULL; @@ -636,10 +636,12 @@ p = n_strncpy(newlang, lang, q - lang + 1); - if ((q = strchr(lang, '.'))) - n_strncpy(p, q, strlen(q) + 1); - else if ((q = strchr(lang, '@'))) - n_strncpy(p, q, strlen(q) + 1); + if ((c = strchr(q, '.'))) + n_strncpy(p, c, strlen(c) + 1); + else if ((c = strchr(q, '@'))) + n_strncpy(p, c, strlen(c) + 1); + + n_assert(strlen(lang) > strlen(newlang)); return newlang; }