From c4b7921819d640a622b311a1f8cb652ddcabf40f Mon Sep 17 00:00:00 2001 From: gitlost Date: Tue, 31 Aug 2021 18:34:29 +0100 Subject: [PATCH] library.c: error_tag(): check error_number < ZINT_ERROR on WARN_FAIL_ALL --- ChangeLog | 1 + backend/library.c | 2 +- backend/tests/test_library.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index a740a8fa..c2551d9f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -14,6 +14,7 @@ Changes Bugs ---- - GUI/CLI: fix dev version test +- library.c: error_tag(): check error_number < ZINT_ERROR on WARN_FAIL_ALL Version 2.10.0 2021-08-14 diff --git a/backend/library.c b/backend/library.c index f81f1a02..e4389125 100644 --- a/backend/library.c +++ b/backend/library.c @@ -218,7 +218,7 @@ STATIC_UNLESS_ZINT_TEST int error_tag(struct zint_symbol *symbol, int error_numb const char *fmt = error_number >= ZINT_ERROR ? error_fmt : warn_fmt; char error_buffer[100]; - if (symbol->warn_level == WARN_FAIL_ALL) { + if (error_number < ZINT_ERROR && symbol->warn_level == WARN_FAIL_ALL) { /* Convert to error equivalent */ if (error_number == ZINT_WARN_NONCOMPLIANT) { error_number = ZINT_ERROR_NONCOMPLIANT; diff --git a/backend/tests/test_library.c b/backend/tests/test_library.c index f5891c19..0fe4860a 100644 --- a/backend/tests/test_library.c +++ b/backend/tests/test_library.c @@ -717,12 +717,14 @@ static void test_error_tag(int index) { /* 4*/ { ZINT_WARN_NONCOMPLIANT, -1, "", ZINT_WARN_NONCOMPLIANT, "Warning " }, /* 5*/ { ZINT_WARN_NONCOMPLIANT, WARN_FAIL_ALL, "", ZINT_ERROR_NONCOMPLIANT, "Error " }, /* 6*/ { ZINT_ERROR_TOO_LONG, WARN_DEFAULT, "", ZINT_ERROR_TOO_LONG, "Error " }, - /* 7*/ { ZINT_WARN_USES_ECI, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, - /* 8*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, - /* 9*/ { ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, - /* 10*/ { ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, - /* 11*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, - /* 12*/ { ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, + /* 7*/ { ZINT_ERROR_TOO_LONG, WARN_FAIL_ALL, "", ZINT_ERROR_TOO_LONG, "Error " }, + /* 8*/ { ZINT_WARN_USES_ECI, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, + /* 9*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, + /* 10*/ { ZINT_ERROR_INVALID_DATA, -1, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, + /* 11*/ { ZINT_ERROR_INVALID_DATA, WARN_FAIL_ALL, "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, + /* 12*/ { ZINT_WARN_USES_ECI, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_WARN_USES_ECI, "Warning 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901" }, + /* 13*/ { ZINT_WARN_USES_ECI, WARN_FAIL_ALL, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_USES_ECI, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, + /* 14*/ { ZINT_ERROR_INVALID_DATA, -1, "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", ZINT_ERROR_INVALID_DATA, "Error 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123" }, }; int data_size = ARRAY_SIZE(data); int i, ret;