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