Module Name: src
Committed By: macallan
Date: Mon Jan 13 19:30:33 UTC 2014
Modified Files:
src/sys/dev/wscons: wsdisplay_glyphcache.c
Log Message:
try not to crash when calling glyphcache_wipe() on an uninitialized cache
first step to fix PR 48492
To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/wscons/wsdisplay_glyphcache.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/wscons/wsdisplay_glyphcache.c
diff -u src/sys/dev/wscons/wsdisplay_glyphcache.c:1.5 src/sys/dev/wscons/wsdisplay_glyphcache.c:1.6
--- src/sys/dev/wscons/wsdisplay_glyphcache.c:1.5 Tue Nov 13 20:29:03 2012
+++ src/sys/dev/wscons/wsdisplay_glyphcache.c Mon Jan 13 19:30:33 2014
@@ -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 firs
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 */