From b38d825e770534067b381f577c5efb859aa2cbe1 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Fri, 28 Oct 2016 00:58:21 +0300 Subject: [PATCH] Eliminate 'possible integer underflow' code defect (cord-de) * cord/tests/de.c (generic_init): Replace initial==CORD_EMPTY check with 0==len where len is CORD_len(initial) (to outline that len-1 cannot cause underflow). --- cord/tests/de.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cord/tests/de.c b/cord/tests/de.c index 84aa4de8..aa1de4db 100644 --- a/cord/tests/de.c +++ b/cord/tests/de.c @@ -552,9 +552,11 @@ void generic_init(void) if ((f = fopen(arg_file_name, "rb")) == NULL) { initial = "\n"; } else { + size_t len; + initial = CORD_from_file(f); - if (initial == CORD_EMPTY - || CORD_fetch(initial, CORD_len(initial)-1) != '\n') { + len = CORD_len(initial); + if (0 == len || CORD_fetch(initial, len - 1) != '\n') { initial = CORD_cat(initial, "\n"); } } -- 2.40.0