Переглянути джерело

Fixed: Correct null pointer dereference

Richard 10 роки тому
батько
коміт
e3ebef0094

+ 8 - 4
tools/assimp_view/Display.cpp

@@ -1320,8 +1320,10 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
         {
             // need to remove the file name
             char* sz = strrchr(szFileName,'\\');
-            if (!sz)sz = strrchr(szFileName,'/');
-            if (!sz)*sz = 0;
+            if (!sz)
+                sz = strrchr(szFileName,'/');
+            if (sz)
+                *sz = 0;
         }
         OPENFILENAME sFilename1 = {
             sizeof(OPENFILENAME),
@@ -1353,8 +1355,10 @@ int CDisplay::HandleTreeViewPopup2(WPARAM wParam,LPARAM lParam)
         {
             // need to remove the file name
             char* sz = strrchr(szFileName,'\\');
-            if (!sz)sz = strrchr(szFileName,'/');
-            if (!sz)*sz = 0;
+            if (!sz)
+                sz = strrchr(szFileName,'/');
+            if (sz)
+                *sz = 0;
         }
         OPENFILENAME sFilename1 = {
             sizeof(OPENFILENAME),

+ 4 - 2
tools/assimp_view/LogWindow.cpp

@@ -168,8 +168,10 @@ void CLogWindow::Save()
     {
         // need to remove the file name
         char* sz = strrchr(szFileName,'\\');
-        if (!sz)sz = strrchr(szFileName,'/');
-        if (!sz)*sz = 0;
+        if (!sz)
+            sz = strrchr(szFileName,'/');
+        if (sz)
+            *sz = 0;
     }
     OPENFILENAME sFilename1 = {
         sizeof(OPENFILENAME),

+ 16 - 8
tools/assimp_view/MessageProc.cpp

@@ -474,8 +474,10 @@ void LoadBGTexture()
     {
         // need to remove the file name
         char* sz = strrchr(szFileName,'\\');
-        if (!sz)sz = strrchr(szFileName,'/');
-        if (!sz)*sz = 0;
+        if (!sz)
+            sz = strrchr(szFileName,'/');
+        if (sz)
+            *sz = 0;
     }
     OPENFILENAME sFilename1 = {
         sizeof(OPENFILENAME),
@@ -597,8 +599,10 @@ void LoadSkybox()
     {
         // need to remove the file name
         char* sz = strrchr(szFileName,'\\');
-        if (!sz)sz = strrchr(szFileName,'/');
-        if (!sz)*sz = 0;
+        if (!sz)
+            sz = strrchr(szFileName,'/');
+        if (sz)
+            *sz = 0;
     }
     OPENFILENAME sFilename1 = {
         sizeof(OPENFILENAME),
@@ -639,8 +643,10 @@ void SaveScreenshot()
     {
         // need to remove the file name
         char* sz = strrchr(szFileName,'\\');
-        if (!sz)sz = strrchr(szFileName,'/');
-        if (!sz)*sz = 0;
+        if (!sz)
+            sz = strrchr(szFileName,'/');
+        if (sz)
+            *sz = 0;
     }
     OPENFILENAME sFilename1 = {
         sizeof(OPENFILENAME),
@@ -938,8 +944,10 @@ void OpenAsset()
     {
         // need to remove the file name
         char* sz = strrchr(szFileName,'\\');
-        if (!sz)sz = strrchr(szFileName,'/');
-        if (!sz)*sz = 0;
+        if (!sz)
+            sz = strrchr(szFileName,'/');
+        if (sz)
+            *sz = 0;
     }
 
     // get a list of all file extensions supported by ASSIMP