Skip to content

CF_UNICODETEXT形式のクリップボードデータをサクラエディタにペーストしたときに u+0000 が追加される不具合を修正#2095

Merged
beru merged 2 commits into
sakura-editor:masterfrom
beru:CF_UNICODETEXT_null_terminating_char
Jun 27, 2025
Merged

Conversation

@beru

@beru beru commented Jun 27, 2025

Copy link
Copy Markdown
Contributor

PR対象

  • アプリ(サクラエディタ本体)

カテゴリ

  • 不具合修正

PR の背景

#2094

仕様・動作説明

PR の影響範囲

テスト内容

関連 issue, PR

#2094

参考資料

@beru beru added the 🐛bug🦋 ■バグ修正(Something isn't working) label Jun 27, 2025
@AppVeyorBot

Copy link
Copy Markdown

Build sakura 1.0.4592 completed (commit 744f673e13 by @beru)

@sonarqubecloud

Copy link
Copy Markdown

@beru

beru commented Jun 27, 2025

Copy link
Copy Markdown
Contributor Author

レビューありがとうございました。Mergeします。

@beru beru merged commit af786a8 into sakura-editor:master Jun 27, 2025
16 checks passed
@beru beru deleted the CF_UNICODETEXT_null_terminating_char branch June 27, 2025 22:48

@berryzplus berryzplus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントできてませんでした。

if( hUnicode != NULL ){
wchar_t* szData = static_cast<wchar_t*>(::GlobalLock(hUnicode));
cmemBuf->Append( szData, GlobalSize(hUnicode)/2);
cmemBuf->Append( szData, GlobalSize(hUnicode) / 2 - 1);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なんとも言えないけど正しくはこんな感じなんでしょうね。

		cmemBuf->Append( szData, wcsnlen(szData, GlobalSize(hUnicode) / 2))

GlobalSizeの戻り値を信用できるかどうかは微妙なので、自前でNUL終端を検索してやるのがベターです。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛bug🦋 ■バグ修正(Something isn't working)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants