mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-25 09:12:24 +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:
parent
10e1ac7752
commit
2357dee0fe
@ -200,9 +200,12 @@ void FUNCTION(CHAR *cmdline, bool includes_program_name,
|
|||||||
* This will guaranteeably be big enough; we can realloc it
|
* This will guaranteeably be big enough; we can realloc it
|
||||||
* down later.
|
* down later.
|
||||||
*/
|
*/
|
||||||
outputline = snewn(1+STRLEN(cmdline), CHAR);
|
{
|
||||||
outputargv = snewn(STRLEN(cmdline)+1 / 2, CHAR *);
|
size_t len = STRLEN(cmdline);
|
||||||
outputargstart = snewn(STRLEN(cmdline)+1 / 2, CHAR *);
|
outputline = snewn(1+len, CHAR);
|
||||||
|
outputargv = snewn((len+1) / 2, CHAR *);
|
||||||
|
outputargstart = snewn((len+1) / 2, CHAR *);
|
||||||
|
}
|
||||||
|
|
||||||
p = cmdline; q = outputline; outputargc = 0;
|
p = cmdline; q = outputline; outputargc = 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user