Fixed major bug: drivers that accepted size arguments could wind

up with more than 80 characters (20x4) in their display, and thus
overwrite memory outside of the allocated 80 characterwframebuffer.

For example, using a 20x6 screen would do this.

All drivers now either ignore a missing framebuffer, or allocate it
themselves - the latter is prefered.
This commit is contained in:
ddouthitt
2001-09-27 23:46:55 +00:00
parent 71c3035611
commit 74153173c1
9 changed files with 16 additions and 57 deletions
+8 -10
View File
@@ -445,18 +445,16 @@ lcd_add_driver (char *driver, char *args)
// Default settings for the driver...
lcd_drv_init(add, NULL);
memset(buf, '\0', sizeof(buf));
add->framebuf = buf; // *** HACK: makes drivers think framebuffer is allocated!
i = init_driver (add, args);
// Allocate space for a framebuffer... *AFTER* the driver
// has a chance to initialize height and width!!
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer for driver \"%s\"", driver);
syslog (LOG_ERR, buf);
// free (add);
return -1;
if (!add->framebuf) {
if ((add->framebuf = malloc (add->wid * add->hgt)) == NULL) {
snprintf (buf, sizeof(buf), "couldn't allocate framebuffer of %d chars for driver \"%s\"",
(add->wid * add->hgt), driver);
syslog (LOG_ERR, buf);
// free (add);
return -1;
}
}
memset (add->framebuf, ' ', (add->wid * add->hgt));