This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 27 Sep 2015 14:22, Paul Pluzhnikov wrote: > --- a/iconv/gconv_db.c > +++ b/iconv/gconv_db.c > @@ -279,6 +279,12 @@ gen_steps (struct derivation_step *best, const char *toset, > if (shlib_handle == NULL) > { > failed = 1; > + > + /* Don't leak memory. BZ #19012. */ > + if (step_cnt == 0) > + free (result[step_cnt].__from_name); > + free (result[*nsteps - 1].__to_name); > + > break; > } what about the other failure case (init_fct returns an error) ? the strduping seems a bit convoluted and makes error handling error prone. what about something a bit more straightforward: char *to_name = NULL; char *from_name = NULL; ... result[step_cnt].__from_name = (step_cnt == 0 ? from_name = __strdup (fromset) : (char *)current->last->result_set); result[step_cnt].__to_name = (step_cnt + 1 == *nsteps ? fo_name = __strdup (current->result_set) : result[step_cnt + 1].__from_name); ... and then in the common clean up at the end: if (__builtin_expect (failed, 0) != 0) { ... free (result); free (to_name); free (from_name); ... -mike
Attachment:
signature.asc
Description: Digital signature
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |