Subject: bug#77325: Crash in Fjson_parse_buffer: ZV changes underneath it?

From: Eli Zaretskii <[email-masked]>
Date: Sat, 29 Mar 2025 18:47:07 +0300

> Date: Sat, 29 Mar 2025 15:37:17 +0000
> From: Pip Cet <[email-masked]>
> Cc: [email-masked], [email-masked]
> 
> The code does seem a bit complicated for what it's trying to achieve, to
> be honest. I think it'd be clearer just to write:
> 
>   unsigned char *begin = PT_ADDR;
>   unsigned char *end = min (GPT_ADDR, ZV_ADDR);
>   unsigned char *secondary_begin = min (GAP_END_ADDR, ZV_ADDR));
>   unsigned char *secondary_end = ZV_ADDR;
> 
>   json_parser_init (&p, conf, begin, end, secondary_begin,
> 		    secondary_end);
> 
> json_parser_init fixes up secondary_begin and secondary_end to be NULL
> pointers in this case.

I'd prefer the secondary_* values to be set NULL explicitly, otherwise
it is hard to understand what the code does without looking deep into
the subroutines of json_parse.