diff options
| author | Bruce Evans <bde@FreeBSD.org> | 2019-03-24 18:57:03 +0000 |
|---|---|---|
| committer | Bruce Evans <bde@FreeBSD.org> | 2019-03-24 18:57:03 +0000 |
| commit | fbc6daa1dc7ed89d794df3ae455ae1f55fad2654 (patch) | |
| tree | d86826964dbd8b06e4431709df588581d94f6d8b /lib/libvgl/bitmap.c | |
| parent | 14243f8de746e756ad3466aa6920a80e39157d9c (diff) | |
Notes
Diffstat (limited to 'lib/libvgl/bitmap.c')
| -rw-r--r-- | lib/libvgl/bitmap.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libvgl/bitmap.c b/lib/libvgl/bitmap.c index f98f533acd1c..aa75daa2ac29 100644 --- a/lib/libvgl/bitmap.c +++ b/lib/libvgl/bitmap.c @@ -338,8 +338,8 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, byte buffer[2048]; /* XXX */ byte *p; - if (width > sizeof(buffer)) { - p = malloc(width); + if (width * src->PixelBytes > sizeof(buffer)) { + p = malloc(width * src->PixelBytes); if (p == NULL) return 1; } else { @@ -349,7 +349,7 @@ __VGLBitmapCopy(VGLBitmap *src, int srcx, int srcy, ReadVerticalLine(src, srcx, srcline, width, p); WriteVerticalLine(dst, dstx, dstline, width, p); } - if (width > sizeof(buffer)) + if (width * src->PixelBytes > sizeof(buffer)) free(p); } return 0; @@ -387,6 +387,7 @@ VGLBitmap object->Xorigin = 0; object->Yorigin = 0; object->Bitmap = bits; + object->PixelBytes = VGLDisplay->PixelBytes; return object; } @@ -401,7 +402,7 @@ VGLBitmapDestroy(VGLBitmap *object) int VGLBitmapAllocateBits(VGLBitmap *object) { - object->Bitmap = (byte *)malloc(object->VXsize*object->VYsize); + object->Bitmap = malloc(object->VXsize*object->VYsize*object->PixelBytes); if (object->Bitmap == NULL) return -1; return 0; |
