]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
Avoid a NULL access when the charset is invalid.
authorBruno Haible <bruno@clisp.org>
Tue, 14 May 2002 17:25:29 +0000 (17:25 +0000)
committerBruno Haible <bruno@clisp.org>
Tue, 23 Jun 2009 10:07:58 +0000 (12:07 +0200)
src/ChangeLog
src/write-po.c

index 1bf50035e4e82ce9abf0d244cfb4a1e213597989..0ef88b3d2aea2e6dbc2a31db613db26aaaed5283 100644 (file)
@@ -1,3 +1,9 @@
+2002-05-14  Bruno Haible  <bruno@clisp.org>
+
+       * write-po.c (wrap): Canonicalize the charset. Handle the case when
+       po_charset_canonicalize returns NULL.
+       Reported by Jan-Marek Glogowski <glogow@stud.fbi.fh-darmstadt.de>.
+
 2002-05-12  Bruno Haible  <bruno@clisp.org>
 
        * po-charset.c (po_charset_canonicalize): Add ISO-8859-14, KOI8-T,
index 521b741b051b8f927ba8739def52c4ad7b20e6f8..7d9f6ed40bf94a30daa421ec92e75d2e9ac9e2a7 100644 (file)
@@ -247,6 +247,7 @@ wrap (fp, line_prefix, name, value, do_wrap, charset)
      enum is_wrap do_wrap;
      const char *charset;
 {
+  const char *canon_charset;
   const char *s;
   bool first_line;
 #if HAVE_ICONV
@@ -255,6 +256,8 @@ wrap (fp, line_prefix, name, value, do_wrap, charset)
 #endif
   bool weird_cjk;
 
+  canon_charset = po_charset_canonicalize (charset);
+
 #if HAVE_ICONV
   /* The old Solaris/openwin msgfmt and GNU msgfmt <= 0.10.35 don't know
      about multibyte encodings, and require a spurious backslash after
@@ -267,20 +270,30 @@ wrap (fp, line_prefix, name, value, do_wrap, charset)
     /* Write a PO file in old format, with extraneous backslashes.  */
     conv = (iconv_t)(-1);
   else
-    /* Avoid glibc-2.1 bug with EUC-KR.  */
-# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
-    if (strcmp (charset, "EUC-KR") == 0)
+    if (canon_charset == NULL)
+      /* Invalid PO file encoding.  */
       conv = (iconv_t)(-1);
     else
+      /* Avoid glibc-2.1 bug with EUC-KR.  */
+# if (__GLIBC__ - 0 == 2 && __GLIBC_MINOR__ - 0 <= 1) && !defined _LIBICONV_VERSION
+      if (strcmp (canon_charset, "EUC-KR") == 0)
+       conv = (iconv_t)(-1);
+      else
 # endif
-    /* Use iconv() to parse multibyte characters.  */
-    conv = iconv_open ("UTF-8", charset);
+      /* Use iconv() to parse multibyte characters.  */
+      conv = iconv_open ("UTF-8", canon_charset);
 
   if (conv != (iconv_t)(-1))
     weird_cjk = false;
   else
 #endif
-    weird_cjk = po_is_charset_weird_cjk (po_charset_canonicalize (charset));
+    if (canon_charset == NULL)
+      weird_cjk = false;
+    else
+      weird_cjk = po_is_charset_weird_cjk (canon_charset);
+
+  if (canon_charset == NULL)
+    canon_charset = po_charset_ascii;
 
   /* Loop over the '\n' delimited portions of value.  */
   s = value;
@@ -528,7 +541,7 @@ internationalized messages should not contain the `\\%c' escape sequence"),
 
       /* Do line breaking on the portion.  */
       mbs_width_linebreaks (portion, portion_len, width, startcol, 0,
-                           overrides, charset, linebreaks);
+                           overrides, canon_charset, linebreaks);
 
       /* If this is the first line, and we are not using the indented
         style, and the line would wrap, then use an empty first line