Skip to content

Commit

Permalink
Oops - off by one error in CF_UNICODETEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
apnadkarni committed Dec 26, 2024
1 parent d6e2851 commit 37ef1fb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion demos/dndSpy.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
## This file implements a drop target that is able to accept any type dropped.
##
## Check Tk version:
package require Tk 8.3
package require Tk 8.3-

if {$::tcl_version == "8.3" && ![package vsatisfies $::tcl_patchLevel 8.3.3]} {
tk_messageBox -type ok -icon error \
Expand Down
4 changes: 2 additions & 2 deletions win/OleDND.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ inline Tcl_Size ObjToWinStringDS(Tcl_Obj *pObj, Tcl_DString *pDS) {
const char *type_str = Tcl_GetStringFromObj(pObj, &type_len);
WCHAR *wtype_str;
Tcl_UtfToWCharDString(type_str, type_len, pDS);
return (Tcl_DStringLength(pDS)/sizeof(WCHAR)) - 1;
return (Tcl_DStringLength(pDS)/sizeof(WCHAR)); // Not including terminator
};

// Copy a Tcl_Obj to a WCHAR buffer. Always terminates the buffer.
Expand All @@ -245,7 +245,7 @@ inline Tcl_Size ObjToWinStringBuffer(Tcl_Obj *pObj, WCHAR *pBuf, Tcl_Size max_le
// Always returns non-NULL. HGLOBAL must be GlobalFree'd.
inline HGLOBAL ObjToWinStringHGLOBAL(Tcl_Obj *pObj) {
Tcl_DString ds;
Tcl_Size len = ObjToWinStringDS(pObj, &ds);
Tcl_Size len = ObjToWinStringDS(pObj, &ds); // Does not include terminator
WCHAR *to;
HGLOBAL hGlobal = GlobalAlloc(GHND, (len+1) * sizeof(WCHAR));
if (hGlobal == NULL) {
Expand Down

0 comments on commit 37ef1fb

Please sign in to comment.