From: Ivan Maidanski Date: Thu, 27 Oct 2016 21:58:21 +0000 (+0300) Subject: Eliminate 'possible integer underflow' code defect (cord-de) X-Git-Tag: v8.0.0~1063 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=311a0fceb7a6e81da99547f74d520f0ebf43c5ff;p=gc 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). --- diff --git a/cord/tests/de.c b/cord/tests/de.c index 096e7664..bb902de1 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"); } }