Submitted By: Joe Ciccone <jciccone@gmail.com>
Date: 2006-06-19
Initial Package Version: 2.4
Upstream Status: In CVS
Origin: https://bugzilla.samba.org/show_bug.cgi?id=3678
Description: Fixes a problem that showed up in samba. It would fail to
             start with the following error.

smbd: gconv_db.c:232: __gconv_release_step: Assertion `step->__end_fct ==
((void *)0)' failed.

diff -Naur glibc-2.4.orig/iconv/gconv_db.c glibc-2.4/iconv/gconv_db.c
--- glibc-2.4.orig/iconv/gconv_db.c	2005-12-19 02:25:25.000000000 -0500
+++ glibc-2.4/iconv/gconv_db.c	2006-06-19 11:42:00.000000000 -0400
@@ -1,5 +1,5 @@
 /* Provide access to the collection of available transformation modules.
-   Copyright (C) 1997-2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1997-2003, 2004, 2005, 2006 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -227,7 +227,7 @@
       step->__shlib_handle = NULL;
 #endif
     }
-  else
+  else if (step->__shlib_handle == NULL)
     /* Builtin modules should not have end functions.  */
     assert (step->__end_fct == NULL);
 }
diff -Naur glibc-2.4.orig/iconvdata/Makefile glibc-2.4/iconvdata/Makefile
--- glibc-2.4.orig/iconvdata/Makefile	2005-11-16 03:15:54.000000000 -0500
+++ glibc-2.4/iconvdata/Makefile	2006-06-19 11:38:42.000000000 -0400
@@ -65,7 +65,8 @@
 include ../Makeconfig
 
 ifeq (yes,$(build-shared))
-tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4
+tests = bug-iconv1 bug-iconv2 tst-loading tst-e2big tst-iconv4 bug-iconv4 \
+	tst-iconv6
 ifeq ($(have-thread-library),yes)
 tests += bug-iconv3
 endif
diff -Naur glibc-2.4.orig/iconvdata/tst-iconv6.c glibc-2.4/iconvdata/tst-iconv6.c
--- glibc-2.4.orig/iconvdata/tst-iconv6.c	1969-12-31 19:00:00.000000000 -0500
+++ glibc-2.4/iconvdata/tst-iconv6.c	2006-06-19 11:38:42.000000000 -0400
@@ -0,0 +1,35 @@
+/* BZ #2569 */
+
+#include <iconv.h>
+#include <stdio.h>
+
+static int
+do_test (void)
+{
+  iconv_t cd0 = iconv_open ("ISO-8859-7", "UTF-16LE");
+  if (cd0 == (iconv_t) -1)
+    {
+      puts ("first iconv_open failed");
+      return 1;
+    }
+  iconv_t cd1 = iconv_open ("ISO-8859-7", "UTF-16LE");
+  if (cd1 == (iconv_t) -1)
+    {
+      puts ("second iconv_open failed");
+      return 1;
+    }
+  if (iconv_close (cd0) != 0)
+    {
+      puts ("first iconv_close failed");
+      return 1;
+    }
+  if (iconv_close (cd1) != 0)
+    {
+      puts ("second iconv_close failed");
+      return 1;
+    }
+  return 0;
+}
+
+#define TEST_FUNCTION do_test ()
+#include "../test-skeleton.c"
