7f6542
#
7f6542
# Red Hat BZ:
7f6542
# https://bugzilla.redhat.com/show_bug.cgi?id=816647
7f6542
#
7f6542
# ChangeLog
7f6542
#
3432a4
#2013-04-30  Patsy Franklin  <pfrankli@redhat.com>
7f6542
#
7f6542
#	* iconv/gconv_cache.c (find_module): Demangle init_fct before 
7f6542
#	checking for NULL. Mangle __btowc_fct if init_fct is non-NULL.
7f6542
#	* iconv/gconv_db.c (free_derivation): Check that __shlib_handle 
7f6542
#	is non-NULL before demangling the end_fct.  Check for NULL
7f6542
#	end_fct after demangling.
7f6542
#	(__gconv_release_step): Demangle the end_fct before checking 
7f6542
#	it for NULL.   Remove assert on __shlibc_handle != NULL.
7f6542
#	(gen_steps): Don't check btowc_fct for NULL before mangling.  
7f6542
#	Demangle init_fct before checking for NULL.
7f6542
#	(increment_counter): Likewise
7f6542
#	* gconv_dl.c (__gconv_find_shlib): Don't check init_fct or
7f6542
#	end_fct for NULL before mangling.
7f6542
#	* wcsmbs/btowc.c (__btowc): Demangle btowc_fct before checking
7f6542
#	for NULL.
7f6542
#
7f6542
diff -Nrup a/iconv/gconv_cache.c b/iconv/gconv_cache.c
3432a4
--- a/iconv/gconv_cache.c	2012-12-24 22:02:13.000000000 -0500
3432a4
+++ b/iconv/gconv_cache.c	2013-04-30 06:43:24.788684270 -0400
3432a4
@@ -207,17 +207,16 @@ find_module (const char *directory, cons
7f6542
       result->__data = NULL;
7f6542
 
7f6542
       /* Call the init function.  */
7f6542
-      if (result->__init_fct != NULL)
7f6542
-	{
7f6542
-	  __gconv_init_fct init_fct = result->__init_fct;
7f6542
+      __gconv_init_fct init_fct = result->__init_fct;
7f6542
 #ifdef PTR_DEMANGLE
7f6542
-	  PTR_DEMANGLE (init_fct);
7f6542
+      PTR_DEMANGLE (init_fct);
7f6542
 #endif
3432a4
+      if (init_fct != NULL)
7f6542
+	{
7f6542
 	  status = DL_CALL_FCT (init_fct, (result));
7f6542
 
7f6542
 #ifdef PTR_MANGLE
7f6542
-	  if (result->__btowc_fct != NULL)
7f6542
-	    PTR_MANGLE (result->__btowc_fct);
7f6542
+	  PTR_MANGLE (result->__btowc_fct);
7f6542
 #endif
7f6542
 	}
7f6542
     }
7f6542
diff -Nrup a/iconv/gconv_db.c b/iconv/gconv_db.c
3432a4
--- a/iconv/gconv_db.c	2012-12-24 22:02:13.000000000 -0500
3432a4
+++ b/iconv/gconv_db.c	2013-04-30 06:37:16.886521576 -0400
3432a4
@@ -179,16 +179,15 @@ free_derivation (void *p)
7f6542
   size_t cnt;
7f6542
 
7f6542
   for (cnt = 0; cnt < deriv->nsteps; ++cnt)
7f6542
-    if (deriv->steps[cnt].__counter > 0
7f6542
-	&& deriv->steps[cnt].__end_fct != NULL)
7f6542
+    if ((deriv->steps[cnt].__counter > 0)
7f6542
+	&& (deriv->steps[cnt].__shlib_handle != NULL))
7f6542
       {
7f6542
-	assert (deriv->steps[cnt].__shlib_handle != NULL);
7f6542
-
7f6542
 	__gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
7f6542
 #ifdef PTR_DEMANGLE
7f6542
 	PTR_DEMANGLE (end_fct);
7f6542
 #endif
7f6542
-	DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
7f6542
+	if (end_fct != NULL)
7f6542
+	  DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
7f6542
       }
7f6542
 
7f6542
   /* Free the name strings.  */
3432a4
@@ -212,16 +211,12 @@ __gconv_release_step (struct __gconv_ste
7f6542
   if (step->__shlib_handle != NULL && --step->__counter == 0)
7f6542
     {
7f6542
       /* Call the destructor.  */
7f6542
-      if (step->__end_fct != NULL)
7f6542
-	{
7f6542
-	  assert (step->__shlib_handle != NULL);
7f6542
-
7f6542
-	  __gconv_end_fct end_fct = step->__end_fct;
7f6542
+	__gconv_end_fct end_fct = step->__end_fct;
7f6542
 #ifdef PTR_DEMANGLE
7f6542
-	  PTR_DEMANGLE (end_fct);
7f6542
+	PTR_DEMANGLE (end_fct);
7f6542
 #endif
7f6542
-	  DL_CALL_FCT (end_fct, (step));
7f6542
-	}
7f6542
+      if (end_fct != NULL)
7f6542
+	DL_CALL_FCT (end_fct, (step));
7f6542
 
7f6542
 #ifndef STATIC_GCONV
7f6542
       /* Release the loaded module.  */
3432a4
@@ -293,13 +288,11 @@ gen_steps (struct derivation_step *best,
7f6542
 
7f6542
 	      /* Call the init function.  */
7f6542
 	      __gconv_init_fct init_fct = result[step_cnt].__init_fct;
7f6542
-	      if (init_fct != NULL)
7f6542
-		{
7f6542
-		  assert (result[step_cnt].__shlib_handle != NULL);
7f6542
-
7f6542
 # ifdef PTR_DEMANGLE
7f6542
-		  PTR_DEMANGLE (init_fct);
7f6542
+	      PTR_DEMANGLE (init_fct);
7f6542
 # endif
7f6542
+	      if (init_fct != NULL)
7f6542
+		{
7f6542
 		  status = DL_CALL_FCT (init_fct, (&result[step_cnt]));
7f6542
 
7f6542
 		  if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
3432a4
@@ -312,8 +305,7 @@ gen_steps (struct derivation_step *best,
7f6542
 		    }
7f6542
 
7f6542
 # ifdef PTR_MANGLE
7f6542
-		  if (result[step_cnt].__btowc_fct != NULL)
7f6542
-		    PTR_MANGLE (result[step_cnt].__btowc_fct);
7f6542
+		  PTR_MANGLE (result[step_cnt].__btowc_fct);
7f6542
 # endif
7f6542
 		}
7f6542
 	    }
3432a4
@@ -393,16 +385,15 @@ increment_counter (struct __gconv_step *
7f6542
 
7f6542
 	  /* Call the init function.  */
7f6542
 	  __gconv_init_fct init_fct = step->__init_fct;
7f6542
-	  if (init_fct != NULL)
7f6542
-	    {
7f6542
 #ifdef PTR_DEMANGLE
7f6542
-	      PTR_DEMANGLE (init_fct);
7f6542
+	  PTR_DEMANGLE (init_fct);
7f6542
 #endif
7f6542
+	  if (init_fct != NULL)
7f6542
+	    {
7f6542
 	      DL_CALL_FCT (init_fct, (step));
7f6542
 
7f6542
 #ifdef PTR_MANGLE
7f6542
-	      if (step->__btowc_fct != NULL)
7f6542
-		PTR_MANGLE (step->__btowc_fct);
7f6542
+	      PTR_MANGLE (step->__btowc_fct);
7f6542
 #endif
7f6542
 	    }
7f6542
 	}
7f6542
diff -Nrup a/iconv/gconv_dl.c b/iconv/gconv_dl.c
3432a4
--- a/iconv/gconv_dl.c	2012-12-24 22:02:13.000000000 -0500
3432a4
+++ b/iconv/gconv_dl.c	2013-04-30 06:37:16.889521601 -0400
3432a4
@@ -132,10 +132,8 @@ __gconv_find_shlib (const char *name)
7f6542
 
7f6542
 #ifdef PTR_MANGLE
7f6542
 		  PTR_MANGLE (found->fct);
7f6542
-		  if (found->init_fct != NULL)
7f6542
-		    PTR_MANGLE (found->init_fct);
7f6542
-		  if (found->end_fct !=  NULL)
7f6542
-		    PTR_MANGLE (found->end_fct);
7f6542
+		  PTR_MANGLE (found->init_fct);
7f6542
+		  PTR_MANGLE (found->end_fct);
7f6542
 #endif
7f6542
 
7f6542
 		  /* We have succeeded in loading the shared object.  */
7f6542
diff -Nrup a/wcsmbs/btowc.c b/wcsmbs/btowc.c
3432a4
--- a/wcsmbs/btowc.c	2012-12-24 22:02:13.000000000 -0500
3432a4
+++ b/wcsmbs/btowc.c	2013-04-30 06:37:16.891521619 -0400
3432a4
@@ -47,15 +47,15 @@ __btowc (c)
7f6542
   /* Get the conversion functions.  */
7f6542
   fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
7f6542
   __gconv_btowc_fct btowc_fct = fcts->towc->__btowc_fct;
7f6542
+#ifdef PTR_DEMANGLE
7f6542
+  if (fcts->towc->__shlib_handle != NULL)
7f6542
+    PTR_DEMANGLE (btowc_fct);
7f6542
+#endif
7f6542
 
7f6542
   if (__builtin_expect (fcts->towc_nsteps == 1, 1)
7f6542
       && __builtin_expect (btowc_fct != NULL, 1))
7f6542
     {
7f6542
       /* Use the shortcut function.  */
7f6542
-#ifdef PTR_DEMANGLE
7f6542
-      if (fcts->towc->__shlib_handle != NULL)
7f6542
-	PTR_DEMANGLE (btowc_fct);
7f6542
-#endif
7f6542
       return DL_CALL_FCT (btowc_fct, (fcts->towc, (unsigned char) c));
7f6542
     }
7f6542
   else