@@ -10,8 +10,8 @@ Version 2.22
* The following bugs are resolved with this release:
4719, 13064, 14094, 15319, 15467, 15790, 16560, 17269, 17569, 17588,
- 17792, 17912, 17932, 17944, 17949, 17964, 17965, 17967, 17969, 17978,
- 17987, 17991, 17996, 17998, 17999.
+ 17792, 17912, 17916, 17932, 17944, 17949, 17964, 17965, 17967, 17969,
+ 17978, 17987, 17991, 17996, 17998, 17999.
* Character encoding and ctype tables were updated to Unicode 7.0.0, using
new generator scripts contributed by Pravin Satpute and Mike FABIAN (Red
@@ -353,7 +353,14 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
struct gconv_fcts fcts;
struct _IO_codecvt *cc;
char *endp = __strchrnul (cs + 5, ',');
- char ccs[endp - (cs + 5) + 3];
+ const size_t ccs_size = endp - (cs + 5) + 3;
+ const bool alloca_ccs = __libc_use_alloca (ccs_size);
+ char *ccs;
+
+ if (__glibc_likely (alloca_ccs))
+ ccs = alloca (ccs_size);
+ else
+ ccs = malloc (ccs_size);
*((char *) __mempcpy (ccs, cs + 5, endp - (cs + 5))) = '\0';
strip (ccs, ccs);
@@ -365,10 +372,15 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
This means we cannot proceed since the user explicitly asked
for these. */
(void) _IO_file_close_it (fp);
+ if (! __glibc_likely (alloca_ccs))
+ free (ccs);
__set_errno (EINVAL);
return NULL;
}
+ if (! __glibc_likely (alloca_ccs))
+ free (ccs);
+
assert (fcts.towc_nsteps == 1);
assert (fcts.tomb_nsteps == 1);