From 0d78cf71bce2e92b275cd849b7f315439a8955c1 Mon Sep 17 00:00:00 2001 From: Peter Haag Date: Mon, 9 Sep 2024 10:54:15 +0200 Subject: [PATCH] Fix broken length calculation --- src/output/output_csv.c | 4 ++-- src/output/output_json.c | 4 ++-- src/output/output_ndjson.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/output/output_csv.c b/src/output/output_csv.c index 52ee7dca..94699444 100644 --- a/src/output/output_csv.c +++ b/src/output/output_csv.c @@ -84,8 +84,8 @@ typedef char *(*string_function_t)(char *, recordHandle_t *); } while (0) #define STREAMBUFFSIZE 4096 -#define STREAMLEN(ptr) \ - (ptr - streamBuff); \ +#define STREAMLEN(ptr) \ + ((ptrdiff_t)STREAMBUFFSIZE - (ptr - streamBuff)); \ assert((ptr - streamBuff) < STREAMBUFFSIZE) static char *streamBuff = NULL; diff --git a/src/output/output_json.c b/src/output/output_json.c index 98774b26..2e105ed7 100644 --- a/src/output/output_json.c +++ b/src/output/output_json.c @@ -115,8 +115,8 @@ static uint32_t recordCount = 0; } while (0) #define STREAMBUFFSIZE 4096 -#define STREAMLEN(ptr) \ - (ptr - streamBuff); \ +#define STREAMLEN(ptr) \ + ((ptrdiff_t)STREAMBUFFSIZE - (ptr - streamBuff)); \ assert((ptr - streamBuff) < STREAMBUFFSIZE) static char *streamBuff = NULL; diff --git a/src/output/output_ndjson.c b/src/output/output_ndjson.c index 5891df28..362a08a7 100644 --- a/src/output/output_ndjson.c +++ b/src/output/output_ndjson.c @@ -103,8 +103,8 @@ static uint32_t recordCount = 0; } while (0) #define STREAMBUFFSIZE 4096 -#define STREAMLEN(ptr) \ - (ptr - streamBuff); \ +#define STREAMLEN(ptr) \ + ((ptrdiff_t)STREAMBUFFSIZE - (ptr - streamBuff)); \ assert((ptr - streamBuff) < STREAMBUFFSIZE) static char *streamBuff = NULL;