1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-09 17:38:00 +00:00

Fix allocations at the start of split_into_argv.

While doing that parametrisation I noticed three strlen calls that
could obviously be replaced with one - and then I also noticed that
there were missing parens in an expression that should have
been (n+1)/2, making it n + 1/2, i.e. just n, due to integer
arithmetic.

Happily that bug meant we were _over_-allocating rather than under,
but even so, how embarrassing. Fixed.
This commit is contained in:
Simon Tatham 2023-03-15 07:58:05 +00:00
parent 10e1ac7752
commit 2357dee0fe

View File

@ -200,9 +200,12 @@ void FUNCTION(CHAR *cmdline, bool includes_program_name,
* This will guaranteeably be big enough; we can realloc it
* down later.
*/
outputline = snewn(1+STRLEN(cmdline), CHAR);
outputargv = snewn(STRLEN(cmdline)+1 / 2, CHAR *);
outputargstart = snewn(STRLEN(cmdline)+1 / 2, CHAR *);
{
size_t len = STRLEN(cmdline);
outputline = snewn(1+len, CHAR);
outputargv = snewn((len+1) / 2, CHAR *);
outputargstart = snewn((len+1) / 2, CHAR *);
}
p = cmdline; q = outputline; outputargc = 0;