Skip to content

Commit

Permalink
RichString_setLen() minor logic fix
Browse files Browse the repository at this point in the history
Compare "<= RICHSTRING_MAXLEN" rather than "< RICHSTRING_MAXLEN".
RICHSTRING_MAXLEN does not include the terminating L'\0' character and
the internal buffer of a RichString instance has
(RICHSTRING_MAXLEN + 1) elements.

Signed-off-by: Kang-Che Sung <[email protected]>
  • Loading branch information
Explorer09 committed Feb 5, 2025
1 parent 8b874d5 commit 64adba2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion RichString.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ static void RichString_extendLen(RichString* this, int len) {
}

static void RichString_setLen(RichString* this, int len) {
if (len < RICHSTRING_MAXLEN && this->chlen < RICHSTRING_MAXLEN) {
if (len <= RICHSTRING_MAXLEN && this->chlen <= RICHSTRING_MAXLEN) {
RichString_setChar(this, len, 0);
this->chlen = len;
} else {
Expand Down

0 comments on commit 64adba2

Please sign in to comment.