From 4a0e595bd6f01fd64dcee7284b9daca1c6e6764a Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Mon, 12 Apr 2004 05:43:00 +0000 Subject: Extra argument validation from Philippe. --- src/PropSet.cxx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/PropSet.cxx b/src/PropSet.cxx index 70cd46f88..ce5782854 100644 --- a/src/PropSet.cxx +++ b/src/PropSet.cxx @@ -211,7 +211,7 @@ SString &SString::append(const char *sOther, lenpos_t sLenOther, char sep) { } SString &SString::insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther) { - if (!sOther) { + if (!sOther || pos > sLen) { return *this; } if (sLenOther == measure_length) { @@ -230,12 +230,16 @@ SString &SString::insert(lenpos_t pos, const char *sOther, lenpos_t sLenOther) { return *this; } -/** Remove @a len characters from the @a pos position, included. +/** + * Remove @a len characters from the @a pos position, included. * Characters at pos + len and beyond replace characters at pos. * If @a len is 0, or greater than the length of the string * starting at @a pos, the string is just truncated at @a pos. */ void SString::remove(lenpos_t pos, lenpos_t len) { + if (pos >= sLen) { + return; + } if (len < 1 || pos + len >= sLen) { s[pos] = '\0'; sLen = pos; -- cgit v1.2.3