diff options
author | Sebastian Martin Dicke <Sebastianmartindicke@gmx.de> | 2018-02-28 19:06:27 +0100 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-03-16 12:01:24 -0300 |
commit | 2e1f56d934d7de475db5b6ffac0d2915088ed662 (patch) | |
tree | 8bd78c3d917839963f111cdabc04edfcb15074a3 | |
parent | 6ee99566cd97ea17b1bbc02c9e569806ee545545 (diff) |
Changed type of some integer variables to avoid overflows
-rw-r--r-- | StringUtils.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/StringUtils.c b/StringUtils.c index 0578cdea..212d8fef 100644 --- a/StringUtils.c +++ b/StringUtils.c @@ -27,11 +27,11 @@ in the source distribution for its full text. */ char* String_cat(const char* s1, const char* s2) { - int l1 = strlen(s1); - int l2 = strlen(s2); + size_t l1 = strlen(s1); + size_t l2 = strlen(s2); char* out = xMalloc(l1 + l2 + 1); strncpy(out, s1, l1); - strncpy(out+l1, s2, l2+1); + strncpy(out + l1, s2, l2 + 1); return out; } @@ -39,7 +39,7 @@ char* String_trim(const char* in) { while (in[0] == ' ' || in[0] == '\t' || in[0] == '\n') { in++; } - int len = strlen(in); + size_t len = strlen(in); while (len > 0 && (in[len-1] == ' ' || in[len-1] == '\t' || in[len-1] == '\n')) { len--; } @@ -80,7 +80,7 @@ char** String_split(const char* s, char sep, int* n) { s += size + 1; } if (s[0] != '\0') { - int size = strlen(s); + size_t size = strlen(s); char* token = xMalloc(size + 1); strncpy(token, s, size + 1); out[ctr] = token; |