From d6c5aea1a2c5421f6b125f17d2b94a1968d578cc Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 13 Aug 2009 07:53:04 -0400 Subject: [PATCH] safe_strto*() now also checks for empty input --- .../0346329e-7fa7-48d1-a2d9-a510d340edb2/body | 4 ++++ .../0346329e-7fa7-48d1-a2d9-a510d340edb2/values | 8 ++++++++ .../ae1157c8-666e-42ca-a9dd-c2d3f0087b18/body | 6 ++++++ .../ae1157c8-666e-42ca-a9dd-c2d3f0087b18/values | 11 +++++++++++ .../bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/values | 17 +++++++++++++++++ src/sawsim.nw | 8 ++++++++ 6 files changed, 54 insertions(+) create mode 100644 .be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/body create mode 100644 .be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/values create mode 100644 .be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/body create mode 100644 .be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/values create mode 100644 .be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/values diff --git a/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/body b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/body new file mode 100644 index 0000000..651d7e5 --- /dev/null +++ b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/body @@ -0,0 +1,4 @@ +$ bin/sawsim -s folded,hooke,1 -N1 -s unfolded,null -k 'folded,unfolded,bell,{,1}' -q folded +#Force (N) Initial state Final state +sawsim: build/k_model.c:174: bell_k: Assertion `p->knot > 0' failed. +Aborted diff --git a/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/values b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/values new file mode 100644 index 0000000..29ab604 --- /dev/null +++ b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/0346329e-7fa7-48d1-a2d9-a510d340edb2/values @@ -0,0 +1,8 @@ +Author: W. Trevor King + + +Content-type: text/plain + + +Date: Thu, 13 Aug 2009 11:47:58 +0000 + diff --git a/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/body b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/body new file mode 100644 index 0000000..4b460bd --- /dev/null +++ b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/body @@ -0,0 +1,6 @@ +Fixed. Now you get: + +$ bin/sawsim -s folded,hooke,1 -N1 -s unfolded,null -k 'folded,unfolded,bell,{,1}' -q folded +Error: unparsable empty string '' for string_create_bell_param_t +sawsim: build/k_model.c:141: safe_strtod: Assertion `endp != s' failed. +Aborted diff --git a/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/values b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/values new file mode 100644 index 0000000..62e7f02 --- /dev/null +++ b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/comments/ae1157c8-666e-42ca-a9dd-c2d3f0087b18/values @@ -0,0 +1,11 @@ +Author: W. Trevor King + + +Content-type: text/plain + + +Date: Thu, 13 Aug 2009 11:52:12 +0000 + + +In-reply-to: 0346329e-7fa7-48d1-a2d9-a510d340edb2 + diff --git a/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/values b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/values new file mode 100644 index 0000000..19d869c --- /dev/null +++ b/.be/bugs/bc85f1a9-d7af-4af9-bbe3-a1d5c25e9d61/values @@ -0,0 +1,17 @@ +creator: W. Trevor King + + +reporter: W. Trevor King + + +severity: minor + + +status: open + + +summary: safe_strto*() should check for blank strings + + +time: Thu, 13 Aug 2009 11:47:22 +0000 + diff --git a/src/sawsim.nw b/src/sawsim.nw index be36e71..96a786b 100644 --- a/src/sawsim.nw +++ b/src/sawsim.nw @@ -1126,6 +1126,10 @@ static int safe_strtoi(const char *s, const char *description) { fprintf(stderr, "Error: unparsable '%s' while parsing '%s' for %s\n", endp, s, description); assert(1==0); //strlen(endp) == 0); + } if (endp == s) { + fprintf(stderr, "Error: unparsable empty string '%s' for %s\n", + s, description); + assert(endp != s); } else if (errno == ERANGE) { fprintf(stderr, "Error: '%s' out of range for %s\n", s, description); assert(errno != ERANGE); @@ -1142,6 +1146,10 @@ static double safe_strtod(const char *s, const char *description) { fprintf(stderr, "Error: unparsable '%s' while parsing '%s' for %s\n", endp, s, description); assert(1==0); //strlen(endp) == 0); + } if (endp == s) { + fprintf(stderr, "Error: unparsable empty string '%s' for %s\n", + s, description); + assert(endp != s); } else if (errno == ERANGE) { fprintf(stderr, "Error: '%s' out of range for %s\n", s, description); assert(errno != ERANGE); -- 2.26.2