diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc
index 3e84cbf..e6435f7 100644
--- a/splash/SplashFTFont.cc
+++ b/splash/SplashFTFont.cc
@@ -241,6 +241,9 @@ GBool SplashFTFont::makeGlyph(int c, int xFrac, int yFrac,
   } else {
     rowSize = (bitmap->w + 7) >> 3;
   }
+  if (rowSize == 0 || bitmap->h == 0) {
+    return gFalse;
+  }
   bitmap->data = (Guchar *)gmallocn_checkoverflow(rowSize, bitmap->h);
   if (!bitmap->data) {
     return gFalse;
