ref: 11b83f7dd56472170a866245501a4f5c6cfd7112
parent: b54825b3e5327ee8f1f54e2fbccf9ac2b3c15968
author: halfwit <michaelmisch1985@gmail.com>
date: Thu Oct 15 09:36:38 PDT 2020
Add in badrect
--- /dev/null
+++ b/libdraw/badrect.c
@@ -1,0 +1,20 @@
+#include "draw.h"
+
+/*
+ * check for zero, negative size or insanely huge rectangle.
+ */
+int
+badrect(Rectangle r)
+{
+ int x, y;
+ unsigned int z;
+
+ x = Dx(r);
+ y = Dy(r);
+ if(x > 0 && y > 0){
+ z = x*y;
+ if(z/x == y && z < 0x10000000)
+ return 0;
+ }
+ return 1;
+}
--- a/libdraw/meson.build
+++ b/libdraw/meson.build
@@ -1,6 +1,7 @@
libdraw_src = [
'alloc.c',
'arith.c',
+ 'badrect.c',
'buildfont.c',
'bytesperline.c',
'chan.c',