aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTatsuya Kinoshita <tats@debian.org>2013-08-04 07:27:00 +0000
committerTatsuya Kinoshita <tats@debian.org>2013-08-04 07:27:00 +0000
commit8164da9e3e3a679bfa94b477674882922d6e28c8 (patch)
treef8668084173b6899ef1560715f34b036b1d9cc2c
parentMerge from upstream on 2012-05-22 (diff)
downloadw3m-8164da9e3e3a679bfa94b477674882922d6e28c8.tar.gz
w3m-8164da9e3e3a679bfa94b477674882922d6e28c8.zip
Check length for Strchop()
Diffstat (limited to '')
-rw-r--r--Str.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Str.c b/Str.c
index e5a0982..eff82a4 100644
--- a/Str.c
+++ b/Str.c
@@ -278,8 +278,8 @@ void
Strchop(Str s)
{
STR_LENGTH_CHECK(s);
- while ((s->ptr[s->length - 1] == '\n' || s->ptr[s->length - 1] == '\r') &&
- s->length > 0) {
+ while (s->length > 0 &&
+ (s->ptr[s->length - 1] == '\n' || s->ptr[s->length - 1] == '\r')) {
s->length--;
}
s->ptr[s->length] = '\0';