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