diff options
author | Nick Mathewson <nickm@torproject.org> | 2016-06-16 15:36:08 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2016-06-16 15:36:08 -0400 |
commit | 128ab31c649d3e9ecef284fa3f751dbea13682a6 (patch) | |
tree | 20be124c95618de39d37dda6ff199e4ba8264a73 /src/common | |
parent | dd73787190ebe9821f8c3574fc1c08d54314699e (diff) | |
download | tor-128ab31c649d3e9ecef284fa3f751dbea13682a6.tar.gz tor-128ab31c649d3e9ecef284fa3f751dbea13682a6.zip |
Mark code unreachable in unescape_string()
Also, add tests for it in case someday it does become reachable.
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/common/util.c b/src/common/util.c index 2775dae8e6..a80d96ac9b 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -2823,7 +2823,7 @@ unescape_string(const char *s, char **result, size_t *size_out) if (size_out) *size_out = out - *result; return cp+1; case '\0': - /* LCOV_EXCL_START */ + /* LCOV_EXCL_START -- we caught this in parse_config_from_line. */ tor_fragile_assert(); tor_free(*result); return NULL; @@ -2841,8 +2841,12 @@ unescape_string(const char *s, char **result, size_t *size_out) x1 = hex_decode_digit(cp[2]); x2 = hex_decode_digit(cp[3]); if (x1 == -1 || x2 == -1) { - tor_free(*result); - return NULL; + /* LCOV_EXCL_START */ + /* we caught this above in the initial loop. */ + tor_assert_nonfatal_unreached(); + tor_free(*result); + return NULL; + /* LCOV_EXCL_STOP */ } *out++ = ((x1<<4) + x2); @@ -2868,7 +2872,11 @@ unescape_string(const char *s, char **result, size_t *size_out) cp += 2; break; default: + /* LCOV_EXCL_START */ + /* we caught this above in the initial loop. */ + tor_assert_nonfatal_unreached(); tor_free(*result); return NULL; + /* LCOV_EXCL_STOP */ } break; default: |