summaryrefslogtreecommitdiff
path: root/cord
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2016-10-28 00:58:21 +0300
committerIvan Maidanski <ivmai@mail.ru>2016-10-28 10:01:28 +0300
commit311a0fceb7a6e81da99547f74d520f0ebf43c5ff (patch)
tree8e5b9019e5674935229e9a6a358d06c374da5f7d /cord
parent0f23ec4e241e5dec0958c6c62ade597a9bb98a75 (diff)
downloadbdwgc-311a0fceb7a6e81da99547f74d520f0ebf43c5ff.tar.gz
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).
Diffstat (limited to 'cord')
-rw-r--r--cord/tests/de.c6
1 files changed, 4 insertions, 2 deletions
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");
}
}