[PATCH] Avoid segfaults on solaris while printing debug msgs in wml_compiler.c

Paul P Komkoff Jr <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Organization Department of Fish & Wildlife
Message-ID <[email protected]>
That's what I'm told


--- gateway/gw/wml_compiler.c	2004-01-22 17:08:24.000000000 +0300
+++ gw/gw/wml_compiler.c	2004-02-07 15:45:17.000000000 +0300
@@ -819,6 +819,7 @@
     int i, pos, wbxml_hex;
     wml_hash_t *temp = NULL;
     Octstr *cut_text = NULL;
+    char* tmp;
 
     /*
      * Beware that libxml2 does internal encoding in UTF-8 while parsing.
@@ -826,12 +827,13 @@
      * to transcode at least here. Only transcode if target encoding differs
      * from libxml2's internal encoding (UTF-8).
      */
+    tmp = xmlGetCharEncodingName(charset);
     if (charset != XML_CHAR_ENCODING_UTF8 && 
         charset_convert(attr_value, "UTF-8", 
-                        (char*) xmlGetCharEncodingName(charset)) != 0) {
+                        tmp) != 0) {
         error(0, "Failed to convert XML attribute value from charset "
                  "<%s> to <%s>, will leave as is.", "UTF-8", 
-                 xmlGetCharEncodingName(charset));
+                 tmp ? tmp : "(undef)");
     }
 
 
@@ -921,6 +923,7 @@
 {
     int ret;
     Octstr *temp;
+    char* tmp;
 
     temp = create_octstr_from_node(node); /* returns string in UTF-8 */
 
@@ -930,12 +933,13 @@
      * to transcode at least here. Only transcode if target encoding differs
      * from libxml2's internal encoding (UTF-8).
      */
+    tmp = xmlGetCharEncodingName(node->doc->charset);
     if (node->doc->charset != XML_CHAR_ENCODING_UTF8 && 
         charset_convert(temp, "UTF-8", 
-                        (char*) xmlGetCharEncodingName(node->doc->charset)) != 0) {
+                        tmp) != 0) {
         error(0, "Failed to convert XML text entity from charset "
                  "<%s> to <%s>, will leave as is.", "UTF-8", 
-                 xmlGetCharEncodingName(node->doc->charset));
+                 tmp ? tmp : "(undef)");
     }
 
     octstr_shrink_blanks(temp);
-- 
Paul P 'Stingray' Komkoff Jr // http://stingr.net/key <- my pgp key
 This message represents the official view of the voices in my head
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.