"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: tog: unconditionally set x/y in view_get_split()
To:
Mark Jamsek <mark@jamsek.com>
Cc:
gameoftrees@openbsd.org
Date:
Thu, 30 Jun 2022 09:05:08 +0200

Download raw body.

Thread
Mark Jamsek <mark@jamsek.com> wrote:
> Suggested by op on irc.
> 
> I noticed this when cooking the diff. We initialise begin_{x,y} in all
> the callers so only conditionally set x/y pointers in view_get_split().
> 
> But for robustness, we should initialise here too.

yep!  what i was thinking is that maybe in the future someone calls
view_get_split without knowing that only one of the pointers is written
to and if they don't initialize the values to something sensible before
it'll be fun :)

> diff 9b058f456d15d60a89334ce3e7f0a7c22e182c55 /Users/mark/Library/Mobile Documents/com~apple~CloudDocs/src/got-current
> blob - 6a0c6dbff39ee1a8db173cbc3fa1fbf0918eecab
> file + tog/tog.c
> --- tog/tog.c
> +++ tog/tog.c
> @@ -2858,6 +2858,9 @@ view_get_split(struct tog_view *view, int *y, int *x)
>  {
>  	char *mode;
> 
> +	*x = 0;
> +	*y = 0;
> +
>  	mode = getenv("TOG_VIEW_SPLIT_MODE");
> 
>  	if (!mode || mode[0] != 'h') {