[PATCH] Pass valid pointer to grid_string_cells or it segfaults
Reproducible with :find-window .. (f) --- grid-view.c |4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/grid-view.c b/grid-view.c index 7ef443a..c639b2a 100644 --- a/grid-view.c +++ b/grid-view.c @@ -229,10 +229,12 @@ grid_view_delete_cells(struct grid *gd, u_int px, u_int py, u_int nx) char * grid_view_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) { + struct grid_cell *gc = NULL; + GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx); px = grid_view_x(gd, px); py = grid_view_y(gd, py); - return (grid_string_cells(gd, px, py, nx, NULL, 0, 0, 0)); + return (grid_string_cells(gd, px, py, nx, &gc, 0, 0, 0)); } -- 1.7.9.5 -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: [PATCH] Pass valid pointer to grid_string_cells or it segfaults
Hi Nicholas, First just quick want to say thanks first, switched yesterday to tmux and it's been so sweet. And also love the source code. Thanks. About the patch, this is a bit nitpicking so if you're busy think you can leave this safely for later. - Later in grid_string_cells if(with_codes) is true it dereference lastgc again twice. At the moment it's not called anywhere with if(with_codes) == true and lastgc == NULL but don't know if that's possible in the future. - In cmd_capture_pane_exec it calls grid_string_cells the same way as the patch I sent. Guess that could be brought in line with just passing NULL with your change. Eugene. On Wed, Mar 06, 2013 at 09:57:13AM +, Nicholas Marriott wrote: > Thanks - fixed by checking in grid_string_cells instead. > > > > On Wed, Mar 06, 2013 at 10:24:55AM +0900, eugene everson wrote: > > Reproducible with :find-window .. (f) > > --- > > grid-view.c |4 +++- > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > diff --git a/grid-view.c b/grid-view.c > > index 7ef443a..c639b2a 100644 > > --- a/grid-view.c > > +++ b/grid-view.c > > @@ -229,10 +229,12 @@ grid_view_delete_cells(struct grid *gd, u_int px, > > u_int py, u_int nx) > > char * > > grid_view_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) > > { > > + struct grid_cell *gc = NULL; > > + > > GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx); > > > > px = grid_view_x(gd, px); > > py = grid_view_y(gd, py); > > > > - return (grid_string_cells(gd, px, py, nx, NULL, 0, 0, 0)); > > + return (grid_string_cells(gd, px, py, nx, &gc, 0, 0, 0)); > > } > > -- > > 1.7.9.5 > > > > > > -- > > Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester > > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the > > endpoint security space. For insight on selecting the right partner to > > tackle endpoint security challenges, access the full report. > > http://p.sf.net/sfu/symantec-dev2dev > > ___ > > tmux-users mailing list > > tmux-users@lists.sourceforge.net > > https://lists.sourceforge.net/lists/listinfo/tmux-users -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users
Re: [PATCH] Pass valid pointer to grid_string_cells or it segfaults
Understand, thanks for the explanation. On Wed, Mar 06, 2013 at 11:26:30AM +, Nicholas Marriott wrote: > On Wed, Mar 06, 2013 at 08:02:49PM +0900, eugene everson wrote: > > Hi Nicholas, > > > > First just quick want to say thanks first, switched yesterday to tmux and > > it's been so sweet. And also love the source code. Thanks. > > > > About the patch, this is a bit nitpicking so if you're busy think you can > > leave this safely for later. > > > > - Later in grid_string_cells if(with_codes) is true it dereference lastgc > > again twice. At the moment it's not called anywhere with if(with_codes) == > > true and lastgc == NULL but don't know if that's possible in the future. > > It won't be possible and anyone who tries it will find out that it > crashes :-). The last cell is only needed when generating escape > sequences (with_codes = 1), so that the function knows what the state is > across multiple lines and doesn't have to generate extra escape > sequences. > > > > > - In cmd_capture_pane_exec it calls grid_string_cells the same way as > > the patch I sent. Guess that could be brought in line with just passing > > NULL with your change. > > capture-pane does set with_codes to 1 (if you give -e flag) so it needs > to pass in a lastgc pointer. > > Thanks > > > > > Eugene. > > > > On Wed, Mar 06, 2013 at 09:57:13AM +, Nicholas Marriott wrote: > > > Thanks - fixed by checking in grid_string_cells instead. > > > > > > > > > > > > On Wed, Mar 06, 2013 at 10:24:55AM +0900, eugene everson wrote: > > > > Reproducible with :find-window .. (f) > > > > --- > > > > grid-view.c |4 +++- > > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > > > diff --git a/grid-view.c b/grid-view.c > > > > index 7ef443a..c639b2a 100644 > > > > --- a/grid-view.c > > > > +++ b/grid-view.c > > > > @@ -229,10 +229,12 @@ grid_view_delete_cells(struct grid *gd, u_int px, > > > > u_int py, u_int nx) > > > > char * > > > > grid_view_string_cells(struct grid *gd, u_int px, u_int py, u_int nx) > > > > { > > > > + struct grid_cell *gc = NULL; > > > > + > > > > GRID_DEBUG(gd, "px=%u, py=%u, nx=%u", px, py, nx); > > > > > > > > px = grid_view_x(gd, px); > > > > py = grid_view_y(gd, py); > > > > > > > > - return (grid_string_cells(gd, px, py, nx, NULL, 0, 0, 0)); > > > > + return (grid_string_cells(gd, px, py, nx, &gc, 0, 0, 0)); > > > > } > > > > -- > > > > 1.7.9.5 > > > > > > > > > > > > -- > > > > Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester > > > > > > > > Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the > > > > > > > > endpoint security space. For insight on selecting the right partner to > > > > tackle endpoint security challenges, access the full report. > > > > http://p.sf.net/sfu/symantec-dev2dev > > > > ___ > > > > tmux-users mailing list > > > > tmux-users@lists.sourceforge.net > > > > https://lists.sourceforge.net/lists/listinfo/tmux-users -- Symantec Endpoint Protection 12 positioned as A LEADER in The Forrester Wave(TM): Endpoint Security, Q1 2013 and "remains a good choice" in the endpoint security space. For insight on selecting the right partner to tackle endpoint security challenges, access the full report. http://p.sf.net/sfu/symantec-dev2dev ___ tmux-users mailing list tmux-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tmux-users