PR/50413: Vicente Chaves: Check the allocattr return and return an error.
This commit is contained in:
parent
8ca6a9a5c9
commit
c47f805a35
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: wsdisplay_vcons.c,v 1.34 2015/07/19 13:22:42 mlelstv Exp $ */
|
/* $NetBSD: wsdisplay_vcons.c,v 1.35 2015/11/08 16:49:20 christos Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2005, 2006 Michael Lorenz
|
* Copyright (c) 2005, 2006 Michael Lorenz
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
#include <sys/cdefs.h>
|
||||||
__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.34 2015/07/19 13:22:42 mlelstv Exp $");
|
__KERNEL_RCSID(0, "$NetBSD: wsdisplay_vcons.c,v 1.35 2015/11/08 16:49:20 christos Exp $");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
@ -285,15 +285,21 @@ vcons_init_screen(struct vcons_data *vd, struct vcons_screen *scr,
|
||||||
#else
|
#else
|
||||||
cnt = ri->ri_rows * ri->ri_cols;
|
cnt = ri->ri_rows * ri->ri_cols;
|
||||||
#endif
|
#endif
|
||||||
scr->scr_attrs = (long *)malloc(cnt * (sizeof(long) +
|
scr->scr_attrs = malloc(cnt * (sizeof(long) +
|
||||||
sizeof(uint32_t)), M_DEVBUF, M_WAITOK);
|
sizeof(uint32_t)), M_DEVBUF, M_WAITOK);
|
||||||
if (scr->scr_attrs == NULL)
|
if (scr->scr_attrs == NULL)
|
||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
|
|
||||||
scr->scr_chars = (uint32_t *)&scr->scr_attrs[cnt];
|
scr->scr_chars = (uint32_t *)&scr->scr_attrs[cnt];
|
||||||
|
|
||||||
ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG, 0, defattr);
|
i = ri->ri_ops.allocattr(ri, WS_DEFAULT_FG, WS_DEFAULT_BG, 0, defattr);
|
||||||
scr->scr_defattr = *defattr;
|
if (i != 0) {
|
||||||
|
#ifdef DIAGNOSTIC
|
||||||
|
printf("vcons: error allocating attribute %d\n", i);
|
||||||
|
#endif
|
||||||
|
scr->scr_defattr = 0;
|
||||||
|
} else
|
||||||
|
scr->scr_defattr = *defattr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* fill the attribute buffer with *defattr, chars with 0x20
|
* fill the attribute buffer with *defattr, chars with 0x20
|
||||||
|
@ -1140,6 +1146,7 @@ vcons_putwschar(struct vcons_screen *scr, struct wsdisplay_char *wsc)
|
||||||
{
|
{
|
||||||
long attr;
|
long attr;
|
||||||
struct rasops_info *ri;
|
struct rasops_info *ri;
|
||||||
|
int error;
|
||||||
|
|
||||||
KASSERT(scr != NULL && wsc != NULL);
|
KASSERT(scr != NULL && wsc != NULL);
|
||||||
|
|
||||||
|
@ -1152,8 +1159,10 @@ vcons_putwschar(struct vcons_screen *scr, struct wsdisplay_char *wsc)
|
||||||
if ((wsc->row >= 0) && (wsc->row < ri->ri_rows) && (wsc->col >= 0) &&
|
if ((wsc->row >= 0) && (wsc->row < ri->ri_rows) && (wsc->col >= 0) &&
|
||||||
(wsc->col < ri->ri_cols)) {
|
(wsc->col < ri->ri_cols)) {
|
||||||
|
|
||||||
ri->ri_ops.allocattr(ri, wsc->foreground, wsc->background,
|
error = ri->ri_ops.allocattr(ri, wsc->foreground,
|
||||||
wsc->flags, &attr);
|
wsc->background, wsc->flags, &attr);
|
||||||
|
if (error)
|
||||||
|
return error;
|
||||||
vcons_putchar(ri, wsc->row, wsc->col, wsc->letter, attr);
|
vcons_putchar(ri, wsc->row, wsc->col, wsc->letter, attr);
|
||||||
#ifdef VCONS_DEBUG
|
#ifdef VCONS_DEBUG
|
||||||
printf("vcons_putwschar(%d, %d, %x, %lx\n", wsc->row, wsc->col,
|
printf("vcons_putwschar(%d, %d, %x, %lx\n", wsc->row, wsc->col,
|
||||||
|
|
Loading…
Reference in New Issue