Replace DEFINEs with consts

This commit is contained in:
Ceyhun Alp 2020-11-26 15:40:28 +00:00
parent 69c93dd259
commit 707dcab5ba
3 changed files with 8 additions and 11 deletions

View file

@ -2,10 +2,10 @@
#include <cairo-pdf.h>
#include "fuzzer_temp_file.h"
#define WIDTH_IN_INCHES 3
#define HEIGHT_IN_INCHES 3
#define WIDTH_IN_POINTS (WIDTH_IN_INCHES * 72.0)
#define HEIGHT_IN_POINTS (HEIGHT_IN_INCHES * 72.0)
const double width_in_inches = 3;
const double height_in_inches = 3;
const double width_in_points = width_in_inches * 72.0;
const double height_in_points = height_in_inches * 72.0;
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cairo_t *cr;
@ -13,7 +13,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cairo_status_t status;
char *tmpfile = fuzzer_get_tmpfile(data, size);
surface = cairo_pdf_surface_create(tmpfile, WIDTH_IN_POINTS, HEIGHT_IN_POINTS);
surface = cairo_pdf_surface_create(tmpfile, width_in_points, height_in_points);
status = cairo_surface_status(surface);
if (status != CAIRO_STATUS_SUCCESS) {
fuzzer_release_tmpfile(tmpfile);

View file

@ -2,9 +2,6 @@
#include <cairo-pdf.h>
#include "fuzzer_temp_file.h"
#define WIDTH 200
#define HEIGHT 80
static cairo_surface_t *
acquire (cairo_pattern_t *pattern, void *closure,
cairo_surface_t *target,

View file

@ -1,10 +1,10 @@
#include <cairo.h>
#include "fuzzer_temp_file.h"
#define GLYPH_RANGE 9
const int glyph_range = 9;
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
if (size < GLYPH_RANGE) {
if (size < glyph_range) {
return 0;
}
cairo_t *cr;
@ -29,7 +29,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
cairo_text_extents(cr, buf, &extents);
cluster.num_bytes = size;
cluster.num_glyphs = 1;
for (int i = 0; i < 9; i++) {
for (int i = 0; i < glyph_range; i++) {
// Taken from test/text-glyph-range.c
cairo_glyph_t glyph = {
(long int)data[i], 10 * i, 25