From 444361272fb5ef59b71aa2b43e1b496667fbdb28 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Thu, 25 Feb 2010 18:01:25 +0000 Subject: [PATCH] From Trajce Nikolov, "attached is some fix for the directshow plugin. Cleans up the build warnings as well makes the code a bit safer" --- src/osgPlugins/directshow/DirectShowTexture.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/osgPlugins/directshow/DirectShowTexture.cpp b/src/osgPlugins/directshow/DirectShowTexture.cpp index 90953fe71..c885c34af 100644 --- a/src/osgPlugins/directshow/DirectShowTexture.cpp +++ b/src/osgPlugins/directshow/DirectShowTexture.cpp @@ -1404,7 +1404,7 @@ bool CTextureRenderer::openFile(const std::string& file) const char *ansistr = file.c_str(); int lenA = lstrlenA(ansistr); int lenW; - BSTR unicodestr; + BSTR unicodestr = 0; lenW = ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, 0, 0); if (lenW > 0) @@ -1414,10 +1414,13 @@ bool CTextureRenderer::openFile(const std::string& file) ::MultiByteToWideChar(CP_ACP, 0, ansistr, lenA, unicodestr, lenW); } - (void)StringCchCopyW(wFileName, NUMELMS(wFileName), unicodestr); + if (unicodestr!=0) + { + (void)StringCchCopyW(wFileName, NUMELMS(wFileName), unicodestr); - // when done, free the BSTR - ::SysFreeString(unicodestr); + // when done, free the BSTR + ::SysFreeString(unicodestr); + } HRESULT hr; if (!initBuildGraph())