diff options
Diffstat (limited to 'CPP/Common/MyWindows.cpp')
-rwxr-xr-x | CPP/Common/MyWindows.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/CPP/Common/MyWindows.cpp b/CPP/Common/MyWindows.cpp index 1283946c..f940fc8a 100755 --- a/CPP/Common/MyWindows.cpp +++ b/CPP/Common/MyWindows.cpp @@ -26,10 +26,13 @@ BSTR SysAllocStringByteLen(LPCSTR psz, UINT len) return 0; *(UINT *)p = len; BSTR bstr = (BSTR)((UINT *)p + 1); - memmove(bstr, psz, len); - Byte *pb = ((Byte *)bstr) + len; - for (int i = 0; i < sizeof(OLECHAR) * 2; i++) - pb[i] = 0; + if (psz) + { + memmove(bstr, psz, len); + Byte *pb = ((Byte *)bstr) + len; + for (unsigned i = 0; i < sizeof(OLECHAR) * 2; i++) + pb[i] = 0; + } return bstr; } |