From 65af864ceb4b30a8126a2ead04f6bbceb5b4d795 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Sun, 29 Mar 2015 17:23:01 +0000 Subject: In vga_load_font(), keep track of the font bits being passed by the caller, should the need to free them arise; and only perform the `use font' logic if we are in the `use font' case (i.e. font->data == NULL). Prompted by a discussion with dan mclaughlin on tech@ --- sys/dev/ic/vga.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'sys') diff --git a/sys/dev/ic/vga.c b/sys/dev/ic/vga.c index 688fbfd2349..cb35acfaa6a 100644 --- a/sys/dev/ic/vga.c +++ b/sys/dev/ic/vga.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vga.c,v 1.63 2014/07/13 23:10:23 deraadt Exp $ */ +/* $OpenBSD: vga.c,v 1.64 2015/03/29 17:23:00 miod Exp $ */ /* $NetBSD: vga.c,v 1.28.2.1 2000/06/30 16:27:47 simonb Exp $ */ /*- @@ -86,14 +86,17 @@ static struct vgafont { int firstchar, numchars; #endif int slot; + void *fontdata; } vga_builtinfont = { - "builtin", - 16, - WSDISPLAY_FONTENC_IBM, + .name = "builtin", + .height = 16, + .encoding = WSDISPLAY_FONTENC_IBM, #ifdef notyet - 0, 256, + .firstchar = 0, + .numchars = 256, #endif - 0 + .slot = 0, + .fontdata = NULL }; int vgaconsole, vga_console_type, vga_console_attached; @@ -838,7 +841,10 @@ vga_load_font(void *v, void *cookie, struct wsdisplay_font *data) int res, slot; struct vgafont *f; - if (scr) { + if (data->data == NULL) { + if (scr == NULL) + return EINVAL; + if ((name2 = data->name) != NULL) { while (*name2 && *name2 != ',') name2++; @@ -846,7 +852,7 @@ vga_load_font(void *v, void *cookie, struct wsdisplay_font *data) *name2++ = '\0'; } res = vga_selectfont(vc, scr, data->name, name2); - if (!res) + if (res == 0) vga_setfont(vc, scr); return (res); } @@ -884,6 +890,7 @@ vga_load_font(void *v, void *cookie, struct wsdisplay_font *data) #endif vga_loadchars(&vc->hdl, slot, 0, 256, f->height, data->data); f->slot = slot; + f->fontdata = data->data; vc->vc_fonts[slot] = f; data->cookie = f; data->index = slot; -- cgit v1.2.3