diff options
author | pfg <pfg@FreeBSD.org> | 2017-05-29 15:24:45 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-05-29 15:24:45 +0000 |
commit | f0afe933460761759eeea85562076b3e0b300b79 (patch) | |
tree | e69b9f7f0a0806ad5a92ce3c0563bcf58ed47a52 | |
parent | 570551aa9657612b4f38a6d34e634c3b45d80967 (diff) | |
download | FreeBSD-src-f0afe933460761759eeea85562076b3e0b300b79.zip FreeBSD-src-f0afe933460761759eeea85562076b3e0b300b79.tar.gz |
MFC r318788:
bhyvegc_resize: make use of reallocarray(3) for bounds-checking.
Also add __FBSDID.
Reviewed by: grehan
-rw-r--r-- | usr.sbin/bhyve/bhyvegc.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/usr.sbin/bhyve/bhyvegc.c b/usr.sbin/bhyve/bhyvegc.c index 377b05b..0987e39 100644 --- a/usr.sbin/bhyve/bhyvegc.c +++ b/usr.sbin/bhyve/bhyvegc.c @@ -1,4 +1,5 @@ #include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); #include <sys/types.h> @@ -56,9 +57,11 @@ bhyvegc_resize(struct bhyvegc *gc, int width, int height) gc_image->width = width; gc_image->height = height; if (!gc->raw) { - gc_image->data = realloc(gc_image->data, - sizeof (uint32_t) * width * height); - memset(gc_image->data, 0, width * height * sizeof (uint32_t)); + gc_image->data = reallocarray(gc_image->data, width * height, + sizeof (uint32_t)); + if (gc_image->data != NULL) + memset(gc_image->data, 0, width * height * + sizeof (uint32_t)); } } |