Skip to content

Commit

Permalink
Wnd_GetText が一文字取りこぼす問題に対処
Browse files Browse the repository at this point in the history
  • Loading branch information
kengoide committed Feb 3, 2021
1 parent 10dda8e commit 2f19369
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sakura_core/apiwrap/StdControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace ApiWrap{

// GetWindowText() はコピーした文字数を返す。
// https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getwindowtextw
const int actualCopied = ::GetWindowText( hWnd, strText.data(), (int)strText.capacity() );
const int actualCopied = ::GetWindowText( hWnd, strText.data(), (int)(strText.capacity() + 1) );
if( actualCopied < 0 ){
// 仕様上は負の場合はありえないが、念の為エラーチェックしておく。
return false;
Expand All @@ -51,7 +51,7 @@ namespace ApiWrap{
return false;
}
}
else if( (int)strText.capacity() <= actualCopied ){
else if( (int)strText.capacity() < actualCopied ){
// GetWindowText() の仕様上はありえないはず
return false;
}
Expand Down

0 comments on commit 2f19369

Please sign in to comment.