summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'leptonica/prog/fuzzing/dewarp_fuzzer.cc')
-rw-r--r--leptonica/prog/fuzzing/dewarp_fuzzer.cc29
1 files changed, 29 insertions, 0 deletions
diff --git a/leptonica/prog/fuzzing/dewarp_fuzzer.cc b/leptonica/prog/fuzzing/dewarp_fuzzer.cc
new file mode 100644
index 00000000..37098a9f
--- /dev/null
+++ b/leptonica/prog/fuzzing/dewarp_fuzzer.cc
@@ -0,0 +1,29 @@
+#include "leptfuzz.h"
+
+extern "C" int
+LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
+{
+ if(size<3) return 0;
+
+ PIX *pixs, *pixd;
+ L_DEWARPA *dewa1;
+ PIXAC *pixac;
+ SARRAY *sa;
+
+ leptSetStdNullHandler();
+
+ pixs = pixReadMemSpix(data, size);
+ if(pixs==NULL) return 0;
+
+ // Don't use debug, because it requires writing to /tmp
+ dewarpSinglePage(pixs, 0, 1, 1, 0, &pixd, NULL, 0);
+
+ pixac = pixacompReadMem(data, size);
+ dewa1 = dewarpaCreateFromPixacomp(pixac, 1, 0, 10, -1);
+
+ dewarpaDestroy(&dewa1);
+ pixacompDestroy(&pixac);
+ pixDestroy(&pixs);
+ pixDestroy(&pixd);
+ return 0;
+}