Skip to content

Commit

Permalink
Fixed overflow bug
Browse files Browse the repository at this point in the history
  • Loading branch information
CandyGumdrop committed Jan 26, 2015
1 parent 6327736 commit 9b164c3
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions ui_edits.h
Original file line number Diff line number Diff line change
Expand Up @@ -252,14 +252,20 @@ static void nick_completion_replace(char_t *nick, uint32_t size)

edit_do(&edit_msg, completion.start, completion.end - completion.start, 1);

memmove(text + completion.end - offset,
text + completion.end, length - completion.end);
memmove(text + completion.end - offset, text + completion.end,
length - offset > edit_msg.maxlength
? edit_msg.maxlength - completion.end + offset
: length - completion.end);

memcpy(text + completion.start, nick, size);

edit_do(&edit_msg, completion.start, size, 0);

edit_msg.length -= offset;
if (length - offset > edit_msg.maxlength) {
edit_msg.length = edit_msg.maxlength;
} else {
edit_msg.length -= offset;
}
completion.end -= offset;
}

Expand Down

0 comments on commit 9b164c3

Please sign in to comment.