mirror of
https://git.code.sf.net/p/zint/code
synced 2025-05-09 13:41:59 -04:00
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:
parent
33135fc146
commit
c7cf006e71
38 changed files with 177 additions and 129 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
@ -65,6 +65,10 @@ jobs:
|
|||
- name: Install libpng-dev
|
||||
run: sudo apt-get install libpng-dev
|
||||
|
||||
- name: Install locale
|
||||
shell: bash
|
||||
run: sudo locale-gen de_DE.UTF-8 && sudo update-locale
|
||||
|
||||
- name: Create Build Environment
|
||||
run: cmake -E make_directory ${{runner.workspace}}/build
|
||||
|
||||
|
|
|
@ -17,7 +17,8 @@ add_definitions(-DZINT_VERSION=\"${ZINT_VERSION}\")
|
|||
|
||||
option(ZINT_DEBUG "Set debug compile flags" OFF)
|
||||
option(ZINT_NOOPT "Set no optimize compile flags" OFF)
|
||||
option(ZINT_SANITIZE "Set sanitize compile/link flags" OFF)
|
||||
option(ZINT_SANITIZE "Set sanitize address/undefined" OFF)
|
||||
option(ZINT_SANITIZEM "Set sanitize memory (ignored if ZINT_SANITIZE)" OFF)
|
||||
option(ZINT_TEST "Set test compile flag" OFF)
|
||||
option(ZINT_COVERAGE "Set code coverage flags" OFF)
|
||||
option(ZINT_SHARED "Build shared library" ON)
|
||||
|
|
31
README.linux
31
README.linux
|
@ -1,4 +1,4 @@
|
|||
% README.linux 2025-02-02
|
||||
% README.linux 2025-02-19
|
||||
% Tested on Ubuntu 20.04.4 LTS, Ubuntu 22.04 LTS, Ubuntu 24.04 LTS and
|
||||
% Fedora Linux 41 (Workstation Edition)
|
||||
|
||||
|
@ -122,21 +122,26 @@ On Fedora you may have to set LD_LIBRARY_PATH for zint ("libzint.so") and zint-q
|
|||
|
||||
A number of options are available:
|
||||
|
||||
ZINT_COVERAGE:BOOL=OFF # Set code coverage flags
|
||||
ZINT_DEBUG:BOOL=OFF # Set debug compile flags
|
||||
ZINT_FRONTEND:BOOL=ON # Build frontend
|
||||
ZINT_NOOPT:BOOL=OFF # Set no optimize compile flags
|
||||
ZINT_SANITIZE:BOOL=OFF # Set sanitize compile/link flags
|
||||
ZINT_SHARED:BOOL=ON # Build shared library
|
||||
ZINT_STATIC:BOOL=OFF # Build static library
|
||||
ZINT_TEST:BOOL=OFF # Set test compile flag
|
||||
ZINT_UNINSTALL:BOOL=ON # Add uninstall target
|
||||
ZINT_USE_PNG:BOOL=ON # Build with PNG support
|
||||
ZINT_USE_QT:BOOL=ON # Build with Qt support
|
||||
ZINT_QT6:BOOL=OFF # If ZINT_USE_QT, use Qt6
|
||||
ZINT_COVERAGE:BOOL=OFF # Set code coverage flags
|
||||
ZINT_DEBUG:BOOL=OFF # Set debug compile flags
|
||||
ZINT_FRONTEND:BOOL=ON # Build frontend
|
||||
ZINT_NOOPT:BOOL=OFF # Set no optimize compile flags
|
||||
ZINT_SANITIZE:BOOL=OFF # Set sanitize compile/link flags
|
||||
ZINT_SANITIZE:BOOL=OFF # Set sanitize address/undefined
|
||||
ZINT_SANITIZEM:BOOL=OFF # Set sanitize memory (ignored if ZINT_SANITIZE)
|
||||
ZINT_SHARED:BOOL=ON # Build shared library
|
||||
ZINT_STATIC:BOOL=OFF # Build static library
|
||||
ZINT_TEST:BOOL=OFF # Set test compile flag
|
||||
ZINT_UNINSTALL:BOOL=ON # Add uninstall target
|
||||
ZINT_USE_PNG:BOOL=ON # Build with PNG support
|
||||
ZINT_USE_QT:BOOL=ON # Build with Qt support
|
||||
ZINT_QT6:BOOL=OFF # If ZINT_USE_QT, use Qt6
|
||||
|
||||
which can be set by doing e.g.
|
||||
|
||||
cmake -DZINT_SANITIZE=ON ..
|
||||
|
||||
Note that ZINT_SANITIZEM (Clang only) is incompatible with ZINT_SANITIZE, and also with
|
||||
ZINT_USE_PNG, unless libpng has also been instrumented with -fsanitize=memory.
|
||||
|
||||
For details on ZINT_TEST and building the zint test suite, see "backend/tests/README".
|
||||
|
|
|
@ -88,6 +88,13 @@ else()
|
|||
message(STATUS "Not using PNG")
|
||||
endif()
|
||||
|
||||
# Incompatible with ZINT_SANITIZE (and also with ZINT_USE_PNG unless libpng instrumented)
|
||||
if(NOT ZINT_SANITIZE AND ZINT_SANITIZEM AND CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
add_compile_options(-fsanitize=memory -fsanitize-memory-track-origins -fno-omit-frame-pointer -O2)
|
||||
link_libraries(-fsanitize=memory)
|
||||
zint_target_compile_definitions(PRIVATE ZINT_SANITIZEM)
|
||||
endif()
|
||||
|
||||
if(ZINT_TEST)
|
||||
zint_target_compile_definitions(PUBLIC ZINT_TEST)
|
||||
endif()
|
||||
|
|
|
@ -108,6 +108,9 @@ INTERNAL int fm_open(struct filemem *restrict const fmp, struct zint_symbol *sym
|
|||
if (!(fmp->mem = (unsigned char *) malloc(FM_PAGE_SIZE))) {
|
||||
return fm_seterr(fmp, ENOMEM);
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(fmp->mem, 0, FM_PAGE_SIZE);
|
||||
#endif
|
||||
fmp->memsize = FM_PAGE_SIZE;
|
||||
if (symbol->memfile) {
|
||||
free(symbol->memfile);
|
||||
|
@ -160,6 +163,9 @@ static int fm_mem_expand(struct filemem *restrict const fmp, const size_t size)
|
|||
fm_clear_mem(fmp);
|
||||
return fm_seterr(fmp, new_size > 0x40000000 ? EINVAL : ENOMEM);
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(new_mem + fmp->memsize, 0, new_size - fmp->memsize);
|
||||
#endif
|
||||
fmp->mem = new_mem;
|
||||
fmp->memsize = new_size;
|
||||
return 1;
|
||||
|
|
|
@ -268,7 +268,7 @@ INTERNAL int gif_pixel_plot(struct zint_symbol *symbol, unsigned char *pixelbuf)
|
|||
if (State.fOutPaged) {
|
||||
State.OutLength = GIF_LZW_PAGE_SIZE;
|
||||
}
|
||||
if (!(State.pOut = (unsigned char *) malloc(State.OutLength))) {
|
||||
if (!(State.pOut = (unsigned char *) calloc(1, State.OutLength))) {
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 614, "Insufficient memory for GIF LZW buffer");
|
||||
}
|
||||
|
||||
|
|
|
@ -115,6 +115,9 @@ static int buffer_plot(struct zint_symbol *symbol, const unsigned char *pixelbuf
|
|||
if (!(symbol->bitmap = (unsigned char *) raster_malloc(bm_bitmap_size, 0 /*prev_size*/))) {
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 661, "Insufficient memory for bitmap buffer");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(symbol->bitmap, 0, bm_bitmap_size);
|
||||
#endif
|
||||
|
||||
if (plot_alpha) {
|
||||
const size_t alpha_size = (size_t) symbol->bitmap_width * symbol->bitmap_height;
|
||||
|
@ -178,10 +181,11 @@ static int save_raster_image_to_file(struct zint_symbol *symbol, const int image
|
|||
}
|
||||
|
||||
if (rotate_angle) {
|
||||
if (!(rotated_pixbuf = (unsigned char *) raster_malloc((size_t) image_width * image_height,
|
||||
0 /*prev_size*/))) {
|
||||
size_t image_size = (size_t) image_width * image_height;
|
||||
if (!(rotated_pixbuf = (unsigned char *) raster_malloc((size_t) image_size, 0 /*prev_size*/))) {
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 650, "Insufficient memory for pixel buffer");
|
||||
}
|
||||
memset(rotated_pixbuf, DEFAULT_PAPER, image_size);
|
||||
}
|
||||
|
||||
/* Rotate image before plotting */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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]);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -48,6 +48,9 @@ static int vector_add_rect(struct zint_symbol *symbol, const float x, const floa
|
|||
errtxt(0, symbol, 691, "Insufficient memory for vector rectangle");
|
||||
return 0;
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(rect, 0, sizeof(struct zint_vector_rect));
|
||||
#endif
|
||||
|
||||
rect->next = NULL;
|
||||
rect->x = x;
|
||||
|
@ -73,6 +76,9 @@ static int vector_add_hexagon(struct zint_symbol *symbol, const float x, const f
|
|||
if (!(hexagon = (struct zint_vector_hexagon *) malloc(sizeof(struct zint_vector_hexagon)))) {
|
||||
return errtxt(0, symbol, 692, "Insufficient memory for vector hexagon");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(hexagon, 0, sizeof(struct zint_vector_hexagon));
|
||||
#endif
|
||||
hexagon->next = NULL;
|
||||
hexagon->x = x;
|
||||
hexagon->y = y;
|
||||
|
@ -96,6 +102,9 @@ static int vector_add_circle(struct zint_symbol *symbol, const float x, const fl
|
|||
if (!(circle = (struct zint_vector_circle *) malloc(sizeof(struct zint_vector_circle)))) {
|
||||
return errtxt(0, symbol, 693, "Insufficient memory for vector circle");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(circle, 0, sizeof(struct zint_vector_circle));
|
||||
#endif
|
||||
circle->next = NULL;
|
||||
circle->x = x;
|
||||
circle->y = y;
|
||||
|
@ -121,6 +130,9 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
|
|||
if (!(string = (struct zint_vector_string *) malloc(sizeof(struct zint_vector_string)))) {
|
||||
return errtxt(0, symbol, 694, "Insufficient memory for vector string");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(string, 0, sizeof(struct zint_vector_string));
|
||||
#endif
|
||||
string->next = NULL;
|
||||
string->x = x;
|
||||
string->y = y;
|
||||
|
@ -133,6 +145,9 @@ static int vector_add_string(struct zint_symbol *symbol, const unsigned char *te
|
|||
free(string);
|
||||
return errtxt(0, symbol, 695, "Insufficient memory for vector string text");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(string->text, 0, string->length + 1);
|
||||
#endif
|
||||
memcpy(string->text, text, string->length);
|
||||
string->text[string->length] = '\0';
|
||||
|
||||
|
@ -444,6 +459,9 @@ INTERNAL int plot_vector(struct zint_symbol *symbol, int rotate_angle, int file_
|
|||
if (!(vector = symbol->vector = (struct zint_vector *) malloc(sizeof(struct zint_vector)))) {
|
||||
return errtxt(ZINT_ERROR_MEMORY, symbol, 696, "Insufficient memory for vector header");
|
||||
}
|
||||
#ifdef ZINT_SANITIZEM /* Suppress clang -fsanitize=memory false positive */
|
||||
memset(vector, 0, sizeof(struct zint_vector));
|
||||
#endif
|
||||
vector->rectangles = NULL;
|
||||
vector->hexagons = NULL;
|
||||
vector->circles = NULL;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2008 by BogDan Vatra *
|
||||
* bogdan@licentia.eu *
|
||||
* Copyright (C) 2010-2023 Robin Stuart *
|
||||
* Copyright (C) 2010-2025 Robin Stuart *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
|
@ -107,7 +107,7 @@ public:
|
|||
|
||||
/* Dotty mode */
|
||||
bool dotty() const; // `symbol->input_mode | BARCODE_DOTTY_MODE`
|
||||
void setDotty(bool botty);
|
||||
void setDotty(bool dotty);
|
||||
|
||||
/* Size of dots used in BARCODE_DOTTY_MODE */
|
||||
float dotSize() const; // `symbol->dot_size`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue