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