diff options
| author | macallan <macallan@NetBSD.org> | 2014-01-13 19:30:33 +0000 |
|---|---|---|
| committer | macallan <macallan@NetBSD.org> | 2014-01-13 19:30:33 +0000 |
| commit | f307dab4353e35dcbcd38fc64279a3b9a2cc15ed (patch) | |
| tree | 735443a3371d03278da78be5cb15bf7d04dd1b52 /sys/dev | |
| parent | f370c824e2670c86ec2b68d6686815a0a0be2a26 (diff) | |
try not to crash when calling glyphcache_wipe() on an uninitialized cache
first step to fix PR 48492
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/wscons/wsdisplay_glyphcache.c | 7 |
1 files changed, 6 insertions, 1 deletions
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 */ |
