From f307dab4353e35dcbcd38fc64279a3b9a2cc15ed Mon Sep 17 00:00:00 2001 From: macallan Date: Mon, 13 Jan 2014 19:30:33 +0000 Subject: try not to crash when calling glyphcache_wipe() on an uninitialized cache first step to fix PR 48492 --- sys/dev/wscons/wsdisplay_glyphcache.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'sys/dev') diff --git a/sys/dev/wscons/wsdisplay_glyphcache.c b/sys/dev/wscons/wsdisplay_glyphcache.c index 0d89a76515f..cfea521508f 100644 --- a/sys/dev/wscons/wsdisplay_glyphcache.c +++ b/sys/dev/wscons/wsdisplay_glyphcache.c @@ -1,4 +1,4 @@ -/* $NetBSD: wsdisplay_glyphcache.c,v 1.5 2012/11/13 20:29:03 macallan Exp $ */ +/* $NetBSD: wsdisplay_glyphcache.c,v 1.6 2014/01/13 19:30:33 macallan Exp $ */ /* * Copyright (c) 2012 Michael Lorenz @@ -67,6 +67,8 @@ glyphcache_init(glyphcache *gc, int first, int lines, int width, gc->gc_cellheight = cellheight; gc->gc_firstline = first; gc->gc_cellsperline = width / cellwidth; + gc->gc_buckets = NULL; + gc->gc_numbuckets = 0; if (lines < 0) lines = 0; cache_lines = lines / cellheight; gc->gc_numcells = cache_lines * gc->gc_cellsperline; @@ -124,6 +126,9 @@ glyphcache_wipe(glyphcache *gc) gc_bucket *b; int i, j, idx; + if ((gc->gc_buckets == NULL) || (gc->gc_numbuckets < 1)) + return; + idx = gc->gc_buckets[0].gb_index; /* empty all the buckets */ -- cgit