diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2008-10-06 18:31:03 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2008-10-06 18:31:03 +0000 |
commit | 9e3adc98267ce80cfbae96d2d4c045ba063e3eac (patch) | |
tree | a5fbed6b2d01d138e60a9dea20d67e0254abc137 /sys/dev/wscons | |
parent | 5830f6829d423e942077bb28817d2bcc7aa06e1d (diff) |
Add missing checks for sc_focus being NULL. Found the hard way by
Jesus Sanchez.
Diffstat (limited to 'sys/dev/wscons')
-rw-r--r-- | sys/dev/wscons/wsdisplay.c | 47 |
1 files changed, 31 insertions, 16 deletions
diff --git a/sys/dev/wscons/wsdisplay.c b/sys/dev/wscons/wsdisplay.c index 2d4afc5abfe..03a45bcc96e 100644 --- a/sys/dev/wscons/wsdisplay.c +++ b/sys/dev/wscons/wsdisplay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: wsdisplay.c,v 1.86 2008/06/07 20:34:36 miod Exp $ */ +/* $OpenBSD: wsdisplay.c,v 1.87 2008/10/06 18:31:02 miod Exp $ */ /* $NetBSD: wsdisplay.c,v 1.82 2005/02/27 00:27:52 perry Exp $ */ /* @@ -233,6 +233,7 @@ void wsdisplay_common_attach(struct wsdisplay_softc *sc, const struct wsdisplay_accessops *accessops, void *accesscookie, u_int defaultscreens); int wsdisplay_common_detach(struct wsdisplay_softc *, int); +void wsdisplay_kbdholdscr(struct wsscreen *, int); #ifdef WSDISPLAY_COMPAT_RAWKBD int wsdisplay_update_rawkbd(struct wsdisplay_softc *, struct wsscreen *); @@ -906,7 +907,7 @@ wsdisplayclose(dev_t dev, int flag, int mode, struct proc *p) /* XXX RESET KEYBOARD LEDS, etc. */ s = spltty(); /* avoid conflict with keyboard */ - wsdisplay_kbdholdscreen((struct device *)sc, 0); + wsdisplay_kbdholdscr(scr, 0); splx(s); } tp = scr->scr_tty; @@ -2011,13 +2012,8 @@ wsscreen_switchwait(struct wsdisplay_softc *sc, int no) } void -wsdisplay_kbdholdscreen(struct device *dev, int hold) +wsdisplay_kbdholdscr(struct wsscreen *scr, int hold) { - struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev; - struct wsscreen *scr; - - scr = sc->sc_focus; - if (hold) scr->scr_hold_screen = 1; else { @@ -2026,6 +2022,17 @@ wsdisplay_kbdholdscreen(struct device *dev, int hold) } } +void +wsdisplay_kbdholdscreen(struct device *dev, int hold) +{ + struct wsdisplay_softc *sc = (struct wsdisplay_softc *)dev; + struct wsscreen *scr; + + scr = sc->sc_focus; + if (scr != NULL) + wsdisplay_kbdholdscr(scr, hold); +} + #if NWSKBD > 0 void wsdisplay_set_console_kbd(struct wsevsrc *src) @@ -2153,6 +2160,9 @@ wsscrollback(void *arg, int op) struct wsdisplay_softc *sc = arg; int lines; + if (sc->sc_focus == NULL) + return; + if (op == WSDISPLAY_SCROLL_RESET) lines = 0; else { @@ -2219,7 +2229,7 @@ wsdisplay_shutdownhook(void *arg) * wsmoused(8) support functions */ -/* pointer to the current screen wsdisplay_softc structure */ +/* XXX pointer to the current screen wsdisplay_softc structure */ static struct wsdisplay_softc *sc = NULL; /* @@ -2234,16 +2244,21 @@ wsmoused(struct wsdisplay_softc *ws_sc, u_long cmd, caddr_t data, if (cmd == WSDISPLAYIO_WSMOUSED) { if (IS_MOTION_EVENT(mouse_event.type)) { - motion_event(mouse_event.type, mouse_event.value); + if (ws_sc->sc_focus != NULL) + motion_event(mouse_event.type, + mouse_event.value); return (0); } if (IS_BUTTON_EVENT(mouse_event.type)) { - /* XXX tv_sec contains the number of clicks */ - if (mouse_event.type == WSCONS_EVENT_MOUSE_DOWN) { - button_event(mouse_event.value, - mouse_event.time.tv_sec); - } else - button_event(mouse_event.value, 0); + if (ws_sc->sc_focus != NULL) { + /* XXX tv_sec contains the number of clicks */ + if (mouse_event.type == + WSCONS_EVENT_MOUSE_DOWN) { + button_event(mouse_event.value, + mouse_event.time.tv_sec); + } else + button_event(mouse_event.value, 0); + } return (0); } if (IS_CTRL_EVENT(mouse_event.type)) { |