general: cmake: add ZINT_SANITIZEM (clang -fsanitize=memory) option

and suppress errors in lib and backend tests (pretty sure they're
  nearly all false positives apart from maybe 2 non-initializations
  in "gif.c" (`pOut` buffer) and "raster.c" (`rotated_pixbuf`)
github: install de_DE.UTF-8 locale in ubuntu-debug also
This commit is contained in:
gitlost 2025-02-19 01:15:58 +00:00
parent 33135fc146
commit c7cf006e71
38 changed files with 177 additions and 129 deletions

View file

@ -77,7 +77,7 @@ static void test_large(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[4096];
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol);
@ -128,47 +128,47 @@ static void test_hrt(const testCtx *const p_ctx) {
/* 4*/ { BARCODE_C25STANDARD, 2, -1, "123456789", "123456789" }, /* Suppresses printing of check digit */
/* 5*/ { BARCODE_C25STANDARD, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" }, /* Unless plain HRT */
/* 6*/ { BARCODE_C25INTER, -1, -1, "123456789", "0123456789" }, /* Adds leading zero if odd */
/* 6*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "123456789", "0123456789" },
/* 7*/ { BARCODE_C25INTER, 1, -1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */
/* 8*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 9*/ { BARCODE_C25INTER, 2, -1, "123456789", "123456789" },
/* 10*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 11*/ { BARCODE_C25INTER, -1, -1, "1234567890", "1234567890" }, /* No leading zero if even */
/* 12*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "1234567890", "1234567890" },
/* 13*/ { BARCODE_C25INTER, 1, -1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */
/* 14*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
/* 15*/ { BARCODE_C25INTER, 2, -1, "1234567890", "01234567890" },
/* 16*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
/* 17*/ { BARCODE_C25IATA, -1, -1, "123456789", "123456789" },
/* 18*/ { BARCODE_C25IATA, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 19*/ { BARCODE_C25IATA, 1, -1, "123456789", "1234567895" },
/* 20*/ { BARCODE_C25IATA, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 21*/ { BARCODE_C25IATA, 2, -1, "123456789", "123456789" },
/* 22*/ { BARCODE_C25IATA, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 23*/ { BARCODE_C25LOGIC, -1, -1, "123456789", "123456789" },
/* 24*/ { BARCODE_C25LOGIC, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 25*/ { BARCODE_C25LOGIC, 1, -1, "123456789", "1234567895" },
/* 26*/ { BARCODE_C25LOGIC, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 27*/ { BARCODE_C25LOGIC, 2, -1, "123456789", "123456789" },
/* 28*/ { BARCODE_C25LOGIC, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 29*/ { BARCODE_C25IND, -1, -1, "123456789", "123456789" },
/* 30*/ { BARCODE_C25IND, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 31*/ { BARCODE_C25IND, 1, -1, "123456789", "1234567895" },
/* 32*/ { BARCODE_C25IND, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 33*/ { BARCODE_C25IND, 2, -1, "123456789", "123456789" },
/* 34*/ { BARCODE_C25IND, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 35*/ { BARCODE_DPLEIT, -1, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
/* 36*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567890" },
/* 37*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345.678.901.236" },
/* 38*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901236" },
/* 39*/ { BARCODE_DPIDENT, -1, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
/* 40*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "123456789", "001234567890" },
/* 41*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "12.34 5.678.901 6" },
/* 42*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "12345678901", "123456789016" },
/* 43*/ { BARCODE_ITF14, -1, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
/* 44*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567895" },
/* 45*/ { BARCODE_ITF14, -1, -1, "1234567890123", "12345678901231" },
/* 46*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901231" },
/* 7*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "123456789", "0123456789" },
/* 8*/ { BARCODE_C25INTER, 1, -1, "123456789", "1234567895" }, /* Unless check digit added when it becomes even */
/* 9*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 10*/ { BARCODE_C25INTER, 2, -1, "123456789", "123456789" },
/* 11*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 12*/ { BARCODE_C25INTER, -1, -1, "1234567890", "1234567890" }, /* No leading zero if even */
/* 13*/ { BARCODE_C25INTER, -1, BARCODE_PLAIN_HRT, "1234567890", "1234567890" },
/* 14*/ { BARCODE_C25INTER, 1, -1, "1234567890", "012345678905" }, /* Unless check digit added when it becomes odd */
/* 15*/ { BARCODE_C25INTER, 1, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
/* 16*/ { BARCODE_C25INTER, 2, -1, "1234567890", "01234567890" },
/* 17*/ { BARCODE_C25INTER, 2, BARCODE_PLAIN_HRT, "1234567890", "012345678905" },
/* 18*/ { BARCODE_C25IATA, -1, -1, "123456789", "123456789" },
/* 19*/ { BARCODE_C25IATA, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 20*/ { BARCODE_C25IATA, 1, -1, "123456789", "1234567895" },
/* 21*/ { BARCODE_C25IATA, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 22*/ { BARCODE_C25IATA, 2, -1, "123456789", "123456789" },
/* 23*/ { BARCODE_C25IATA, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 24*/ { BARCODE_C25LOGIC, -1, -1, "123456789", "123456789" },
/* 25*/ { BARCODE_C25LOGIC, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 26*/ { BARCODE_C25LOGIC, 1, -1, "123456789", "1234567895" },
/* 27*/ { BARCODE_C25LOGIC, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 28*/ { BARCODE_C25LOGIC, 2, -1, "123456789", "123456789" },
/* 29*/ { BARCODE_C25LOGIC, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 30*/ { BARCODE_C25IND, -1, -1, "123456789", "123456789" },
/* 31*/ { BARCODE_C25IND, -1, BARCODE_PLAIN_HRT, "123456789", "123456789" },
/* 32*/ { BARCODE_C25IND, 1, -1, "123456789", "1234567895" },
/* 33*/ { BARCODE_C25IND, 1, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 34*/ { BARCODE_C25IND, 2, -1, "123456789", "123456789" },
/* 35*/ { BARCODE_C25IND, 2, BARCODE_PLAIN_HRT, "123456789", "1234567895" },
/* 36*/ { BARCODE_DPLEIT, -1, -1, "123456789", "00001.234.567.890" }, /* Leading zeroes added to make 13 + appended checksum */
/* 37*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567890" },
/* 38*/ { BARCODE_DPLEIT, -1, -1, "1234567890123", "12345.678.901.236" },
/* 39*/ { BARCODE_DPLEIT, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901236" },
/* 40*/ { BARCODE_DPIDENT, -1, -1, "123456789", "00.12 3.456.789 0" }, /* Leading zeroes added to make 11 + appended checksum */
/* 41*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "123456789", "001234567890" },
/* 42*/ { BARCODE_DPIDENT, -1, -1, "12345678901", "12.34 5.678.901 6" },
/* 43*/ { BARCODE_DPIDENT, -1, BARCODE_PLAIN_HRT, "12345678901", "123456789016" },
/* 44*/ { BARCODE_ITF14, -1, -1, "123456789", "00001234567895" }, /* Leading zeroes added to make 13 + appended checksum */
/* 45*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "123456789", "00001234567895" },
/* 46*/ { BARCODE_ITF14, -1, -1, "1234567890123", "12345678901231" },
/* 47*/ { BARCODE_ITF14, -1, BARCODE_PLAIN_HRT, "1234567890123", "12345678901231" },
};
const int data_size = ARRAY_SIZE(data);
int i, length, ret;

View file

@ -43,7 +43,7 @@ INTERNAL int u_big5_test(const unsigned int u, unsigned char *dest);
/* Version of `u_big5()` taking unsigned int destination for backward-compatible testing */
static int u_big5_int(unsigned int u, unsigned int *d) {
unsigned char dest[2];
unsigned char dest[2] = {0}; /* Suppress clang -fsanitize=memory false positive */
int ret = u_big5_test(u, dest);
if (ret) {
*d = ret == 1 ? dest[0] : ((dest[0] << 8) | dest[1]);
@ -157,6 +157,8 @@ static int big5_utf8(struct zint_symbol *symbol, const unsigned char source[], i
unsigned int i, length;
unsigned int *utfdata = (unsigned int *) z_alloca(sizeof(unsigned int) * (*p_length + 1));
memset(utfdata, 0, sizeof(unsigned int) * (*p_length + 1)); /* Suppress clang -fsanitize=memory false positive */
error_number = utf8_to_unicode(symbol, source, utfdata, p_length, 0 /*disallow_4byte*/);
if (error_number != 0) {
return error_number;

View file

@ -155,7 +155,7 @@ static void test_print(const testCtx *const p_ctx) {
char expected_file[4096];
char escaped[1024];
int escaped_size = 1024;
unsigned char filebuf[32768];
unsigned char filebuf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
int filebuf_size;
const char *const have_identify = testUtilHaveIdentify();

View file

@ -55,7 +55,7 @@ static void test_large(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[4096];
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol);

View file

@ -103,7 +103,7 @@ static void test_large(const testCtx *const p_ctx) {
char escaped2[1024];
char cmp_buf[8192];
char cmp_msg[1024];
char ret_buf[8192];
char ret_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */

View file

@ -342,7 +342,7 @@ static void test_not_sane_lookup(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
int test_length;
int posns[32];
int posns[32] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_not_sane_lookup");
@ -666,7 +666,7 @@ static void test_utf8_to_unicode(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
unsigned int vals[20];
unsigned int vals[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
struct zint_symbol s_symbol;
struct zint_symbol *symbol = &s_symbol;

View file

@ -1534,7 +1534,7 @@ static void test_examples(const testCtx *const p_ctx) {
char escaped[1024];
char esc_composite[4096];
char bwipp_buf[32768];
char bwipp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -1836,7 +1836,7 @@ static void test_ean128_cc_shift(const testCtx *const p_ctx) {
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -2384,7 +2384,7 @@ static void test_encodation_0(const testCtx *const p_ctx) {
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -2522,7 +2522,7 @@ static void test_encodation_10(const testCtx *const p_ctx) {
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -2938,7 +2938,7 @@ static void test_encodation_11(const testCtx *const p_ctx) {
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -3089,7 +3089,7 @@ static void test_addongap(const testCtx *const p_ctx) {
int i, length, composite_length, ret;
struct zint_symbol *symbol = NULL;
char bwipp_buf[8192];
char bwipp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char bwipp_msg[1024];
const char *composite = "[91]12";

View file

@ -758,7 +758,7 @@ static void test_utf8_to_eci_ascii(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length, ret;
char dest[128];
char dest[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_utf8_to_eci_ascii");
@ -815,7 +815,7 @@ static void test_utf8_to_eci_utf16be(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int out_length, eci_length;
char dest[1024];
char dest[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (testContinue(p_ctx, i)) continue;
@ -880,7 +880,7 @@ static void test_utf8_to_eci_utf16le(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int out_length, eci_length;
char dest[1024];
char dest[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (testContinue(p_ctx, i)) continue;
@ -942,7 +942,7 @@ static void test_utf8_to_eci_utf32be(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int out_length, eci_length;
char dest[1024];
char dest[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (testContinue(p_ctx, i)) continue;
@ -1006,7 +1006,7 @@ static void test_utf8_to_eci_utf32le(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int out_length, eci_length;
char dest[1024];
char dest[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (testContinue(p_ctx, i)) continue;

View file

@ -96,7 +96,7 @@ static void test_svg(const testCtx *const p_ctx) {
assert_equal(symbol->memfile_size, expected_size, "i:%d memfile_size %d != %d (%s)\n",
i, symbol->memfile_size, expected_size, symbol->errtxt);
ret = memcmp(symbol->memfile, data[i].expected, symbol->memfile_size);
ret = memcmp(symbol->memfile, data[i].expected, expected_size);
assert_zero(ret, "i:%d memcmp() %d != 0\n", i, ret);
} else {
assert_null(symbol->memfile, "i:%d memfile != NULL (%s)\n", i, symbol->errtxt);
@ -147,7 +147,7 @@ static void test_putsf(const testCtx *const p_ctx) {
struct zint_symbol symbol_data = {0};
struct zint_symbol *const symbol = &symbol_data;
struct filemem fm;
struct filemem fm = {0}; /* Suppress clang -fsanitize=memory false positive */
struct filemem *const fmp = &fm;
#ifndef ZINT_TEST_NO_FMEMOPEN
FILE *fp;
@ -338,7 +338,7 @@ static void test_seek(const testCtx *const p_ctx) {
int j;
struct zint_symbol symbol_data = {0};
struct zint_symbol *const symbol = &symbol_data;
struct filemem fm;
struct filemem fm = {0}; /* Suppress clang -fsanitize=memory false positive */
struct filemem *const fmp = &fm;
const char outfile[] = "test_seek.tst";

View file

@ -282,7 +282,7 @@ static void test_gb18030_utf8(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol symbol = {0};
unsigned int gbdata[30];
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_utf8");
@ -399,7 +399,7 @@ static void test_gb18030_utf8_to_eci(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length, ret;
unsigned int gbdata[30];
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_utf8_to_eci");
@ -455,7 +455,7 @@ static void test_gb18030_cpy(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length;
unsigned int gbdata[30];
unsigned int gbdata[30] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb18030_cpy");

View file

@ -188,7 +188,7 @@ static void test_gb2312_utf8(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol symbol = {0};
unsigned int gbdata[20];
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_utf8");
@ -290,7 +290,7 @@ static void test_gb2312_utf8_to_eci(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length, ret;
unsigned int gbdata[20];
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_utf8_to_eci");
@ -346,7 +346,7 @@ static void test_gb2312_cpy(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length;
unsigned int gbdata[20];
unsigned int gbdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_gb2312_cpy");

View file

@ -1446,9 +1446,9 @@ static void test_gs1_verify(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024];
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char escaped[1024];
testStartSymbol("test_gs1_verify", &symbol);
@ -2154,9 +2154,9 @@ static void test_gs1_lint(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i, length, ret;
struct zint_symbol *symbol = NULL;
int reduced_length;
int reduced_length = 0; /* Suppress clang -fsanitize=memory false positive */
char reduced[1024];
char reduced[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_gs1_lint", &symbol);

View file

@ -3452,7 +3452,7 @@ static void test_encode_segs(const testCtx *const p_ctx) {
int i, j, seg_count, ret;
struct zint_symbol *symbol = NULL;
char escaped[8192];
char escaped[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[32768];
char cmp_msg[1024];

View file

@ -239,7 +239,7 @@ static void test_input(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char cmp_buf[8192];
char cmp_buf[8192] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */

View file

@ -44,7 +44,7 @@ INTERNAL int u_ksx1001_test(const unsigned int u, unsigned char *dest);
/* Version of `u_ksx1001()` taking unsigned int destination for backward-compatible testing */
static int u_ksx1001_int(const unsigned int u, unsigned int *d) {
unsigned char dest[2];
unsigned char dest[2] = {0}; /* Suppress clang -fsanitize=memory false positive */
int ret = u_ksx1001_test(u, dest);
if (ret) {
*d = ret == 1 ? dest[0] : ((dest[0] << 8) | dest[1]);

View file

@ -1577,7 +1577,7 @@ static int test_prev_ZBarcode_BarcodeName(int symbol_id, char name[32]) {
static void test_barcode_name(const testCtx *const p_ctx) {
int ret;
char name[32];
char name[32] = {0}; /* Suppress clang -fsanitize=memory false positive */
int symbol_id;
(void)p_ctx;

View file

@ -255,7 +255,7 @@ static void test_input(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[1024];
char cmp_buf[32768];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */

View file

@ -68,7 +68,7 @@ static void test_check_colour_options(const testCtx *const p_ctx) {
};
const int data_size = ARRAY_SIZE(data);
int i, ret;
struct zint_symbol symbol;
struct zint_symbol symbol = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_check_colour_options");
@ -121,7 +121,7 @@ static void test_colour_get_rgb(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
/* Suppress clang-16 run-time exception MemorySanitizer: use-of-uninitialized-value (fixed in clang-17) */
unsigned char red = 0, green = 0, blue = 0, alpha = 0, rgb_alpha = 0;
int cyan, magenta, yellow, black;
int cyan = 0, magenta = 0, yellow = 0, black = 0; /* Suppress clang -fsanitize=memory false positive */
int have_alpha;
char rgb[64];
char cmyk[64];
@ -179,8 +179,9 @@ static void test_colour_get_cmyk(const testCtx *const p_ctx) {
testStart("test_colour_get_cmyk");
for (i = 0; i < data_size; i++) {
int cyan, magenta, yellow, black;
unsigned char red, green, blue, alpha, rgb_alpha;
/* Suppress clang -fsanitize=memory false positives */
int cyan = 0, magenta = 0, yellow = 0, black = 0;
unsigned char red = '\0', green = '\0', blue = '\0', alpha = '\0', rgb_alpha = '\0';
char rgb[16];
if (testContinue(p_ctx, i)) continue;

View file

@ -5762,7 +5762,7 @@ static void test_numbprocess(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i, length;
short chainemc[32];
short chainemc[32] = {0}; /* Suppress clang -fsanitize=memory false positive */
int mclength;
testStart("test_numbprocess");

View file

@ -71,7 +71,7 @@ static void test_large(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[4096];
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol);

View file

@ -82,7 +82,7 @@ static void test_large(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char data_buf[4096];
char data_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_large", &symbol);

View file

@ -235,7 +235,7 @@ static void test_ps_convert(const testCtx *const p_ctx) {
const int data_size = ARRAY_SIZE(data);
int i;
unsigned char converted[256];
unsigned char converted[256] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_ps_convert");

View file

@ -72,8 +72,8 @@ static void test_qr_large(const testCtx *const p_ctx) {
char data_buf[ZINT_MAX_DATA_LEN];
char escaped[ZINT_MAX_DATA_LEN];
char cmp_buf[177 * 177 + 1];
char escaped[ZINT_MAX_DATA_LEN] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[177 * 177 + 1] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -433,7 +433,7 @@ static void test_qr_input(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -763,7 +763,7 @@ static void test_qr_optimize(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
@ -8874,7 +8874,7 @@ static void test_rmqr_encode_segs(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[32768];
char cmp_buf[32768] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */

View file

@ -1,6 +1,6 @@
/*
libzint - the open source barcode library
Copyright (C) 2020-2022 Robin Stuart <rstuart114@gmail.com>
Copyright (C) 2020-2025 Robin Stuart <rstuart114@gmail.com>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
@ -263,7 +263,7 @@ static void test_uint_encoding(const testCtx *const p_ctx) {
for (i = 0; i < data_size; i++) {
int j;
rs_uint_t rs_uint;
rs_uint_t rs_uint = {0}; /* Suppress clang -fsanitize=memory false positive */
unsigned int res[1024];
if (testContinue(p_ctx, i)) continue;

View file

@ -865,7 +865,7 @@ static void test_examples(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol *symbol = NULL;
char escaped[4096];
char escaped[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_buf[16384];
char cmp_msg[1024];

View file

@ -210,7 +210,7 @@ static void test_sjis_utf8(const testCtx *const p_ctx) {
int i, length, ret;
struct zint_symbol symbol = {0};
unsigned int jisdata[20];
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_utf8");
@ -302,7 +302,7 @@ static void test_sjis_utf8_to_eci(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length, ret;
unsigned int jisdata[20];
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_utf8_to_eci");
@ -354,7 +354,7 @@ static void test_sjis_cpy(const testCtx *const p_ctx) {
int data_size = ARRAY_SIZE(data);
int i, length;
unsigned int jisdata[20];
unsigned int jisdata[20] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStart("test_sjis_cpy");

View file

@ -99,8 +99,8 @@ static void test_upce_input(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[4096];
char cmp_msg[1024];
char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */
int do_zxingcpp = (debug & ZINT_DEBUG_TEST_ZXINGCPP) && testUtilHaveZXingCPPDecoder(); /* Only do ZXing-C++ test if asked, too slow otherwise */
@ -834,7 +834,7 @@ static void test_vector_same(const testCtx *const p_ctx) {
}
for (j = 0; j < vectors_size; j++) {
struct zint_symbol symbol_vector;
struct zint_symbol symbol_vector = {0}; /* Suppress clang -fsanitize=memory false positive */
symbol_vector.vector = vectors[j];
vector_free(&symbol_vector);
}
@ -974,7 +974,7 @@ static void test_encode(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
char escaped[4096];
char cmp_buf[4096];
char cmp_buf[4096] = {0}; /* Suppress clang -fsanitize=memory false positive */
char cmp_msg[1024];
int do_bwipp = (debug & ZINT_DEBUG_TEST_BWIPP) && testUtilHaveGhostscript(); /* Only do BWIPP test if asked, too slow otherwise */

View file

@ -689,7 +689,7 @@ static void test_buffer_vector(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
const char *text;
char errmsg[128];
char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_buffer_vector", &symbol);
@ -858,7 +858,7 @@ static void test_has_hrt(const testCtx *const p_ctx) {
struct zint_symbol *symbol = NULL;
const char *text;
char errmsg[128];
char errmsg[128] = {0}; /* Suppress clang -fsanitize=memory false positive */
testStartSymbol("test_has_hrt", &symbol);

View file

@ -1869,8 +1869,8 @@ int testUtilCmpTxts(const char *txt1, const char *txt2) {
int ret = -1;
FILE *fp1;
FILE *fp2;
char buf1[1024];
char buf2[1024];
char buf1[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char buf2[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
size_t len1 = 0, len2 = 0;
fp1 = testUtilOpen(txt1, "r");
@ -1920,8 +1920,8 @@ int testUtilCmpBins(const char *bin1, const char *bin2) {
int ret = -1;
FILE *fp1;
FILE *fp2;
char buf1[1024];
char buf2[1024];
char buf1[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char buf2[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
size_t len1 = 0, len2 = 0;
fp1 = testUtilOpen(bin1, "rb");
@ -1970,8 +1970,8 @@ int testUtilCmpEpss(const char *eps1, const char *eps2) {
int ret = -1;
FILE *fp1;
FILE *fp2;
char buf1[1024];
char buf2[1024];
char buf1[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
char buf2[1024] = {0}; /* Suppress clang -fsanitize=memory false positive */
size_t len1 = 0, len2 = 0;
static char first_line[] = "%!PS-Adobe-3.0 EPSF-3.0\n";
static char second_line_start[] = "%%Creator: Zint ";
@ -2053,7 +2053,7 @@ const char *testUtilHaveIdentify(void) {
/* Check raster files */
int testUtilVerifyIdentify(const char *const prog, const char *filename, int debug) {
char cmd[512 + 128];
char cmd[512 + 128] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (strlen(filename) > 512) {
return -1;
@ -2210,7 +2210,7 @@ int testUtilHaveTiffInfo(void) {
/* Check TIF files */
int testUtilVerifyTiffInfo(const char *filename, int debug) {
char cmd[512 + 128];
char cmd[512 + 128] = {0}; /* Suppress clang -fsanitize=memory false positive */
if (strlen(filename) > 512) {
return -1;