diff options
author | Nick Mathewson <nickm@torproject.org> | 2014-04-25 01:24:39 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2014-04-25 01:24:39 -0400 |
commit | d3c05a79f0b3e688e43edfffe9886664777517f7 (patch) | |
tree | caf18aa657f83c5bf224bd2750dc5e81d2000e3d /src/common/memarea.c | |
parent | 12b1d64b0378450fb8c69dfe81fde2d1cd1b36b1 (diff) | |
parent | 5470795b834a788ec482f22091d58b27a1999a2d (diff) | |
download | tor-d3c05a79f0b3e688e43edfffe9886664777517f7.tar.gz tor-d3c05a79f0b3e688e43edfffe9886664777517f7.zip |
Merge branch 'scanbuild_fixes'
Diffstat (limited to 'src/common/memarea.c')
-rw-r--r-- | src/common/memarea.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/src/common/memarea.c b/src/common/memarea.c index e2d07fca9e..bcaea0949e 100644 --- a/src/common/memarea.c +++ b/src/common/memarea.c @@ -291,14 +291,11 @@ memarea_strdup(memarea_t *area, const char *s) char * memarea_strndup(memarea_t *area, const char *s, size_t n) { - size_t ln; + size_t ln = 0; char *result; - const char *cp, *end = s+n; tor_assert(n < SIZE_T_CEILING); - for (cp = s; cp < end && *cp; ++cp) + for (ln = 0; ln < n && s[ln]; ++ln) ; - /* cp now points to s+n, or to the 0 in the string. */ - ln = cp-s; result = memarea_alloc(area, ln+1); memcpy(result, s, ln); result[ln]='\0'; |