summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichał Cichoń <michcic@gmail.com>2015-08-25 18:28:18 +0200
committerMichał Cichoń <michcic@gmail.com>2015-08-25 18:28:18 +0200
commit1e7c49969628dcd42d937d194359d11fc74ee650 (patch)
treeb7810d291dd072ef744fa4b914394dbab175a4ed /src
parent4f43140468cefba39573d1efbded5258fcc56c93 (diff)
downloadpianobar-windows-1e7c49969628dcd42d937d194359d11fc74ee650.tar.gz
pianobar-windows-1e7c49969628dcd42d937d194359d11fc74ee650.tar.bz2
pianobar-windows-1e7c49969628dcd42d937d194359d11fc74ee650.zip
Fix text copied to clipboard being cropped.
Diffstat (limited to 'src')
-rw-r--r--src/console.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/console.c b/src/console.c
index 09d3116..af105b2 100644
--- a/src/console.c
+++ b/src/console.c
@@ -384,22 +384,23 @@ void BarConsoleEraseLine (int mode) {
void BarConsoleSetClipboard(const char* text) {
WCHAR* wideString;
HANDLE stringHandle;
- size_t wideSize;
+ size_t wideSize, wideBytes;
wideSize = MultiByteToWideChar(CP_UTF8, 0, text, -1, NULL, 0);
- wideString = calloc(1, (wideSize + 1) * sizeof(WCHAR));
+ wideBytes = wideSize * sizeof(WCHAR);
+ wideString = malloc(wideBytes);
if (!wideString)
return;
MultiByteToWideChar(CP_UTF8, 0, text, -1, wideString, wideSize);
- stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideSize);
+ stringHandle = GlobalAlloc(GMEM_MOVEABLE, wideBytes);
if (!stringHandle) {
free(wideString);
return;
}
- memcpy(GlobalLock(stringHandle), wideString, wideSize);
+ memcpy(GlobalLock(stringHandle), wideString, wideBytes);
GlobalUnlock(stringHandle);