[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: LYNX-DEV Bad bug in Lynx 2.6
From: |
Bela Lubkin |
Subject: |
Re: LYNX-DEV Bad bug in Lynx 2.6 |
Date: |
Sat, 2 Nov 1996 17:28:56 -0800 |
Alan Rooks wrote:
> About a week ago I asked for help because I'd compiled Lynx on my IRIX 5.3 box
> and it was locking up. I've since discovered the problem, and it's a pretty
> bad one... I'm surprised others haven't found it.
>
> The problem was that the display_lines variable was being stomped on by
> something. Turned out it was code in GridText.c that was initializing an
> array of length MAX_LINE+1, but the code thought the array had length
> LINESIZE. Since MAX_LINE is 1024 and LINESIZE is 4096, all hell broke loose.
> Note that I've changed the code to initialize MAX_LINE bytes with the
> appropriate character and then NUL-terminate, since the buffers are allocated
> MAX_LINE+1 bytes. I'm assuming that this was what was intended when the
> arrays were declared with size MAX_LINE+1.
>
> Is there a reason why this isn't done with memset()? And while I'm at it, is
> there a reason that underscore_string is filled with dots (instead of
> underscores) and star_string is filled with underscores (instead of stars)?
Other parts of Lynx require memset() (e.g.: main()), so it apparently
doesn't cause a portability problem.
So here's another version of your patch, using memset() and sizeof.
>Bela<
*** GridText.c.orig Thu Oct 17 08:48:54 1996
--- GridText.c Sat Nov 2 17:27:32 1996
***************
*** 163,168 ****
--- 189,198 ----
* Memory leak fixed.
* 05-29-94 Lynx 2-3-1 Garrett Arch Blythe
* Changed to arrays.
+ *
+ * 11-02-96 Bela Lubkin
+ * CAUTION: code below uses "sizeof" on these arrays, so will need
+ * to be changed if these ever become pointers.
*/
PRIVATE char underscore_string[MAX_LINE + 1];
PUBLIC char star_string[MAX_LINE + 1];
***************
*** 282,294 ****
* if the underline is not filled with dots.
*/
if (underscore_string[0] != '.') { /* Make a line */
! char *p;
! for (p=underscore_string; p<underscore_string+(MAX_LINE-1); p++)
! *p = '.'; /* Used for printfs later */
! underscore_string[(MAX_LINE-1)] = '\0';
! for (p=star_string; p<star_string+(LINESIZE-1); p++)
! *p = '_'; /* Used for printfs later */
! star_string[(LINESIZE-1)] = '\0';
}
underline_on = FALSE; /* reset */
--- 315,325 ----
* if the underline is not filled with dots.
*/
if (underscore_string[0] != '.') { /* Make a line */
! /* These strings are used for printfs later */
! memset(underscore_string, '.', sizeof underscore_string);
! underscore_string[sizeof underscore_string - 1] = '\0';
! memset(star_string, '.', sizeof star_string);
! star_string[sizeof star_string - 1] = '\0';
}
underline_on = FALSE; /* reset */
;
; To UNSUBSCRIBE: Send a mail message to address@hidden
; with "unsubscribe lynx-dev" (without the
; quotation marks) on a line by itself.
;