Try to work around segfaults on Solaris if NULL is passed for outbuf...
authorOwen Taylor <otaylor@redhat.com>
Wed, 20 Mar 2002 23:24:22 +0000 (23:24 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Wed, 20 Mar 2002 23:24:22 +0000 (23:24 +0000)
Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>

        * glib/gconvert.c (open_converter): Try to work around segfaults
        on Solaris if NULL is passed for outbuf... supposedly gchar
        *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
glib/gconvert.c

index 01307bc..7f32eb5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index 01307bc..7f32eb5 100644 (file)
@@ -1,3 +1,9 @@
+Wed Mar 20 18:20:21 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * glib/gconvert.c (open_converter): Try to work around segfaults
+       on Solaris if NULL is passed for outbuf... supposedly gchar
+       *outbuf = NULL... &outbuf works. (#74336, Lauri Alanko)
+
 Wed Mar 20 11:17:32 2002  Owen Taylor  <otaylor@redhat.com>
 
        * glib/gfileutils.c (get_contents_regfile): Close the
index c12569e..63c251f 100644 (file)
@@ -354,11 +354,19 @@ open_converter (const gchar *to_codeset,
         }
       else
         {
+         /* Apparently iconv on Solaris <= 7 segfaults if you pass in
+          * NULL for anything but inbuf; work around that. (NULL outbuf
+          * or NULL *outbuf is allowed by Unix98.)
+          */
+         gint inbytes_left = 0;
+         gchar *outbuf = NULL;
+         gint outbytes_left = 0;
+               
           cd = bucket->cd;
           bucket->used = TRUE;
           
           /* reset the descriptor */
-          g_iconv (cd, NULL, NULL, NULL, NULL);
+          g_iconv (cd, NULL, &inbytes_left, &outbuf, &outbytes_left);
         }
       
       bucket->refcount++;