3 # https://bugzilla.redhat.com/show_bug.cgi?id=816647
7 #2013-04-30 Patsy Franklin <pfrankli@redhat.com>
9 # * iconv/gconv_cache.c (find_module): Demangle init_fct before
10 # checking for NULL. Mangle __btowc_fct if init_fct is non-NULL.
11 # * iconv/gconv_db.c (free_derivation): Check that __shlib_handle
12 # is non-NULL before demangling the end_fct. Check for NULL
13 # end_fct after demangling.
14 # (__gconv_release_step): Demangle the end_fct before checking
15 # it for NULL. Remove assert on __shlibc_handle != NULL.
16 # (gen_steps): Don't check btowc_fct for NULL before mangling.
17 # Demangle init_fct before checking for NULL.
18 # (increment_counter): Likewise
19 # * gconv_dl.c (__gconv_find_shlib): Don't check init_fct or
20 # end_fct for NULL before mangling.
21 # * wcsmbs/btowc.c (__btowc): Demangle btowc_fct before checking
24 diff -Nrup a/iconv/gconv_cache.c b/iconv/gconv_cache.c
25 --- a/iconv/gconv_cache.c 2012-12-24 22:02:13.000000000 -0500
26 +++ b/iconv/gconv_cache.c 2013-04-30 11:34:20.112389987 -0400
27 @@ -207,17 +207,16 @@ find_module (const char *directory, cons
28 result->__data = NULL;
30 /* Call the init function. */
31 - if (result->__init_fct != NULL)
33 - __gconv_init_fct init_fct = result->__init_fct;
34 + __gconv_init_fct init_fct = result->__init_fct;
36 - PTR_DEMANGLE (init_fct);
37 + PTR_DEMANGLE (init_fct);
39 + if (init_fct != NULL)
41 status = DL_CALL_FCT (init_fct, (result));
44 - if (result->__btowc_fct != NULL)
45 - PTR_MANGLE (result->__btowc_fct);
46 + PTR_MANGLE (result->__btowc_fct);
50 diff -Nrup a/iconv/gconv_db.c b/iconv/gconv_db.c
51 --- a/iconv/gconv_db.c 2012-12-24 22:02:13.000000000 -0500
52 +++ b/iconv/gconv_db.c 2013-04-30 11:32:42.700592914 -0400
53 @@ -179,16 +179,15 @@ free_derivation (void *p)
56 for (cnt = 0; cnt < deriv->nsteps; ++cnt)
57 - if (deriv->steps[cnt].__counter > 0
58 - && deriv->steps[cnt].__end_fct != NULL)
59 + if ((deriv->steps[cnt].__counter > 0)
60 + && (deriv->steps[cnt].__shlib_handle != NULL))
62 - assert (deriv->steps[cnt].__shlib_handle != NULL);
64 __gconv_end_fct end_fct = deriv->steps[cnt].__end_fct;
66 PTR_DEMANGLE (end_fct);
68 - DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
69 + if (end_fct != NULL)
70 + DL_CALL_FCT (end_fct, (&deriv->steps[cnt]));
73 /* Free the name strings. */
74 @@ -212,16 +211,12 @@ __gconv_release_step (struct __gconv_ste
75 if (step->__shlib_handle != NULL && --step->__counter == 0)
77 /* Call the destructor. */
78 - if (step->__end_fct != NULL)
80 - assert (step->__shlib_handle != NULL);
82 - __gconv_end_fct end_fct = step->__end_fct;
83 + __gconv_end_fct end_fct = step->__end_fct;
85 - PTR_DEMANGLE (end_fct);
86 + PTR_DEMANGLE (end_fct);
88 - DL_CALL_FCT (end_fct, (step));
90 + if (end_fct != NULL)
91 + DL_CALL_FCT (end_fct, (step));
94 /* Release the loaded module. */
95 @@ -293,13 +288,11 @@ gen_steps (struct derivation_step *best,
97 /* Call the init function. */
98 __gconv_init_fct init_fct = result[step_cnt].__init_fct;
99 - if (init_fct != NULL)
101 - assert (result[step_cnt].__shlib_handle != NULL);
104 - PTR_DEMANGLE (init_fct);
105 + PTR_DEMANGLE (init_fct);
107 + if (init_fct != NULL)
109 status = DL_CALL_FCT (init_fct, (&result[step_cnt]));
111 if (__builtin_expect (status, __GCONV_OK) != __GCONV_OK)
112 @@ -312,8 +305,7 @@ gen_steps (struct derivation_step *best,
116 - if (result[step_cnt].__btowc_fct != NULL)
117 - PTR_MANGLE (result[step_cnt].__btowc_fct);
118 + PTR_MANGLE (result[step_cnt].__btowc_fct);
122 @@ -393,16 +385,15 @@ increment_counter (struct __gconv_step *
124 /* Call the init function. */
125 __gconv_init_fct init_fct = step->__init_fct;
126 - if (init_fct != NULL)
129 - PTR_DEMANGLE (init_fct);
130 + PTR_DEMANGLE (init_fct);
132 + if (init_fct != NULL)
134 DL_CALL_FCT (init_fct, (step));
137 - if (step->__btowc_fct != NULL)
138 - PTR_MANGLE (step->__btowc_fct);
139 + PTR_MANGLE (step->__btowc_fct);
143 diff -Nrup a/iconv/gconv_dl.c b/iconv/gconv_dl.c
144 --- a/iconv/gconv_dl.c 2012-12-24 22:02:13.000000000 -0500
145 +++ b/iconv/gconv_dl.c 2013-04-30 11:32:42.701592922 -0400
146 @@ -132,10 +132,8 @@ __gconv_find_shlib (const char *name)
149 PTR_MANGLE (found->fct);
150 - if (found->init_fct != NULL)
151 - PTR_MANGLE (found->init_fct);
152 - if (found->end_fct != NULL)
153 - PTR_MANGLE (found->end_fct);
154 + PTR_MANGLE (found->init_fct);
155 + PTR_MANGLE (found->end_fct);
158 /* We have succeeded in loading the shared object. */
159 diff -Nrup a/wcsmbs/btowc.c b/wcsmbs/btowc.c
160 --- a/wcsmbs/btowc.c 2012-12-24 22:02:13.000000000 -0500
161 +++ b/wcsmbs/btowc.c 2013-04-30 11:32:42.701592922 -0400
162 @@ -47,15 +47,15 @@ __btowc (c)
163 /* Get the conversion functions. */
164 fcts = get_gconv_fcts (_NL_CURRENT_DATA (LC_CTYPE));
165 __gconv_btowc_fct btowc_fct = fcts->towc->__btowc_fct;
167 + if (fcts->towc->__shlib_handle != NULL)
168 + PTR_DEMANGLE (btowc_fct);
171 if (__builtin_expect (fcts->towc_nsteps == 1, 1)
172 && __builtin_expect (btowc_fct != NULL, 1))
174 /* Use the shortcut function. */
176 - if (fcts->towc->__shlib_handle != NULL)
177 - PTR_DEMANGLE (btowc_fct);
179 return DL_CALL_FCT (btowc_fct, (fcts->towc, (unsigned char) c));