#include <stdlib.h>
#include <string.h>
#include <assert.h>
+#include <inttypes.h>
#include <errno.h>
#include "pack.h"
unsigned char **new, *tmp;
size_t i;
+ if (height > SIZE_MAX / sizeof *new) {
+ lbx_error_raise(LBX_ENOMEM);
+ return NULL;
+ }
+
+ /* Ensure that there is at least one row in the framebuffer. */
+ if (height == 0 || width == 0)
+ width = height = 1;
+
tmp = calloc(height, width);
if (!tmp) {
lbx_error_raise(LBX_ENOMEM);