changeset 2420:0313c761d203

memory problems, Mouse
author Ritor1
date Wed, 23 Jul 2014 01:12:55 +0600
parents 15440e9ae7b6
children fc7456da5a93
files Actor.cpp GUIProgressBar.cpp LOD.cpp MediaPlayer.cpp Mouse.cpp Mouse.h NPC.cpp OSWindow.cpp PaletteManager.cpp Render.cpp Sprites.cpp mm7_2.cpp stru6.cpp texts.cpp
diffstat 14 files changed, 32 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Actor.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/Actor.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -5277,7 +5277,7 @@
     strcpy(pMonster->pActorName, Src->pName);
     pMonster->sCurrentHP = Src->uHP;
     assert(sizeof(MonsterInfo) == 88);
-    memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));
+    memcpy(&pMonster->pMonsterInfo, Src, sizeof(MonsterInfo));//Uninitialized portail memory access
     pMonster->word_000086_some_monster_id = v50 + 1;
     pMonster->uActorRadius = v27->uMonsterRadius;
     pMonster->uActorHeight = v27->uMonsterHeight;
--- a/GUIProgressBar.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/GUIProgressBar.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -59,7 +59,7 @@
     v6 = (int)&field_10;
     do
     {
-      if ( *(char *)(v6 + v4) == 1 )
+      if ( *(char *)(v6 + v4) == 1 ) //Uninitialized memory access (v6)
         ++v5;
       ++v4;
     }
--- a/LOD.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/LOD.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -1364,7 +1364,7 @@
   if ( !bRewrite_data && (insert_index < uNumSubDirs) )//перезаписывание файлов для освобождения места для нового ф-ла
   {
     for( int i = uNumSubDirs; i > insert_index; --i )
-      memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory));
+      memcpy(&pSubIndices[i], &pSubIndices[i - 1], sizeof(LOD::Directory));	//Uninitialized memory access
   }
   //insert
   memcpy(&pSubIndices[insert_index], pDir, sizeof(LOD::Directory));//записать текущий файл
@@ -1402,7 +1402,7 @@
     to_copy_size -= read_size;
   }
   // add container data
-  fwrite(pDirData, 1, pDir->uDataSize, tmp_file);
+  fwrite(pDirData, 1, pDir->uDataSize, tmp_file);// Uninitialized memory access(tmp_file)
   if ( bRewrite_data )
     fseek(pFile,size_correction , SEEK_CUR);
 
@@ -1715,7 +1715,7 @@
 
   if ( this->uTextureRedBits != uTargetRBits
     || this->uTextureGreenBits != uTargetGBits
-    || this->uTextureBlueBits != uTargetBBits )
+    || this->uTextureBlueBits != uTargetBBits )	 //Uninitialized memory access
   {
     this->uTextureRedBits = uTargetRBits;
     this->uTextureGreenBits = uTargetGBits;
@@ -2242,11 +2242,11 @@
         fread((char *)&eTextureType + 3, 1, 1, pFile);
         fread((char *)&pContainer + 3, 1, 1, pFile);
         fread((char *)&pOutTex + 3, 1, 1, pFile);
-        v8->pPalette16[i] = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(uTextureRedBits)))
-                            << (LOBYTE(uTextureBlueBits) + LOBYTE(uTextureGreenBits));
-        v8->pPalette16[i] += (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(uTextureGreenBits)))
-                            << uTextureBlueBits;
-        v8->pPalette16[i] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(uTextureBlueBits)));
+        v8->pPalette16[i] = (unsigned __int8)(BYTE3(eTextureType) >> (8 - LOBYTE(this->uTextureRedBits))) //Uninitialized memory access
+                            << (LOBYTE(this->uTextureBlueBits) + LOBYTE(this->uTextureGreenBits));
+        v8->pPalette16[i] += (unsigned __int8)(BYTE3(pContainer) >> (8 - LOBYTE(this->uTextureGreenBits)))
+                            << this->uTextureBlueBits;
+        v8->pPalette16[i] += (unsigned __int8)(BYTE3(pOutTex) >> (8 - LOBYTE(this->uTextureBlueBits)));
       }
     }
   }
--- a/MediaPlayer.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/MediaPlayer.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -79,7 +79,7 @@
         auto new_data = new char[new_data_size];//выделение памяти
         //Log::Warning(L"new new_data %u", new_data);
 
-        memcpy(new_data, data, data_size);
+        memcpy(new_data, data, data_size);	  //Invalid partial memory access
         //Log::Warning(L"data delete %u", data);
         delete [] data;//удаление памяти под data
 
@@ -348,7 +348,8 @@
         return;
       }
 
-      if (swr_convert(converter, dst_channels, num_channels * num_samples, (const uint8_t **)channels, num_channels * num_samples) >= 0)
+      if (swr_convert(converter, dst_channels, num_channels * num_samples, (const uint8_t **)channels, num_channels * num_samples) >= 0) //Invalid partial memory access, Uninitialized memory access
+
         stream->Write(dst_channels[0], num_channels * num_samples * sizeof(__int16));
       else
         __debugbreak();
@@ -380,7 +381,7 @@
   do
   {
     //Декодирование аудио-пакета осуществляется функцией avcodec_decode_audio4
-    if (avcodec_decode_audio4(dec_ctx, avframe, (int *)&decoded, avpacket) < 0)
+    if (avcodec_decode_audio4(dec_ctx, avframe, (int *)&decoded, avpacket) < 0)	//Uninitialized portail memory access
     {
       log("Cannot decode audio frame\n");
       return false;
--- a/Mouse.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/Mouse.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -225,7 +225,7 @@
 
   if ( this->bInitialized )
   {
-    if ( !this->field_8 && this->bActive && !this->field_C )
+    if ( !this->field_8 && this->bActive && !this->field_C ) //Uninitialized memory access(this->field_8)
       pMouse->_469AE4();//Ritor1: странная, непонятная функция
     this->field_F4 = 1;
     if ( this->field_C )
--- a/Mouse.h	Tue Jul 22 17:43:28 2014 +0600
+++ b/Mouse.h	Wed Jul 23 01:12:55 2014 +0600
@@ -56,7 +56,10 @@
     pCursorBitmap2_sysmem = nullptr;
     pCursorBitmap3_sysmembits_16bit = nullptr;
     ptr_90 = nullptr;
-    pWard = pWard;
+    pWard = nullptr;
+    *pCurrentCursorName = NULL;
+    uMouseClickX = 0;
+    uMouseClickY = 0;
   }
 
   void GetClickPos(unsigned int *pX, unsigned int *pY);
--- a/NPC.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/NPC.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -946,7 +946,7 @@
     for (uint i=0; i<pNPCStats->uNumNewNPCs; ++i )
         {
         if ( pNPCStats->pNewNPCData[i].uProfession == uProfession && 
-            (pNPCStats->pNewNPCData[i].uFlags & 0x80) )
+            (pNPCStats->pNewNPCData[i].uFlags & 0x80) )//Uninitialized memory access
             return true;
         }
     if ( pParty->pHirelings[0].uProfession == uProfession ||
--- a/OSWindow.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/OSWindow.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -469,7 +469,7 @@
   }
 
   OSWindow* window = (OSWindow *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
-  if (window && window->api_handle == hwnd)
+  if (window && window->api_handle == hwnd)	//Uninitialized memory access
   {
     LPARAM result;
     if (window->WinApiMessageProc(msg, wparam, lparam, &result))
--- a/PaletteManager.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/PaletteManager.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -355,13 +355,13 @@
 
   v2 = this;
   //v3 = (char *)pBaseColors[a2];
-  if (pPalette_tintColor[0] || pPalette_tintColor[1] || pPalette_tintColor[2])
+  if (pPalette_tintColor[0] || pPalette_tintColor[1] || pPalette_tintColor[2]) //Uninitialized memory access
   {
     //v8 = 0;
     //i = 0;
 
     for (uint i = 0; i < 256; ++i)
-      RGB2HSV(&v64[i], &v63[i], (pBaseColors[a2][i][0] + pPalette_tintColor[0]) / (255.0f + 255.0f),
+      RGB2HSV(&v64[i], &v63[i], (pBaseColors[a2][i][0] + pPalette_tintColor[0]) / (255.0f + 255.0f), //Uninitialized memory access
                                 (pBaseColors[a2][i][1] + pPalette_tintColor[1]) / (255.0f + 255.0f),
                                 (pBaseColors[a2][i][2] + pPalette_tintColor[2]) / (255.0f + 255.0f), &a6[i]);
     //do
@@ -566,7 +566,7 @@
 
   //v45 = pPalette_mistColor[0];
   float mist_a, mist_b, mist_c;
-  if (pPalette_mistColor[0] || pPalette_mistColor[1] || pPalette_mistColor[2])
+  if (pPalette_mistColor[0] || pPalette_mistColor[1] || pPalette_mistColor[2]) //Uninitialized memory access
   {
     //v46 = (double)v45;
     //v80 = pPalette_mistColor[1];
--- a/Render.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/Render.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -802,7 +802,7 @@
       {
         delete [] v20.pDriverName;
         delete [] v20.pDeviceDesc;
-        free(v20.pDDraw4DevDesc);
+        delete [] v20.pDDraw4DevDesc;
         delete v20.pGUID;
         v6 = (IUnknown *)pDirectDraw4;
       }
@@ -813,7 +813,7 @@
         pDirect3D3->EnumDevices((LPD3DENUMDEVICESCALLBACK)D3DDeviceEnumerator, &aux);
         delete [] v20.pDriverName;
         delete [] v20.pDeviceDesc;
-        free(v20.pDDraw4DevDesc);
+        delete [] v20.pDDraw4DevDesc;
         delete v20.pGUID;
         pDirectDraw4->Release();
         v6 = (IUnknown *)pDirect3D3;
@@ -1879,7 +1879,7 @@
     Point.x = 0;
     ClientToScreen(hWindow, &Point);
     OffsetRect(&rc, Point.x, Point.y);
-    pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0);
+    pFrontBuffer->Blt(&rc, pBackBuffer, &v5, DDBLT_WAIT, 0);//Uninitialized memory access
   }
   else
     pFrontBuffer->Flip(0, 1);
@@ -2757,7 +2757,7 @@
         for ( test_byte = 1; test_byte < 63; ++test_byte )
         {
           v15 = i + test_byte;
-          if ( lineRGB[v15] != pict_byte )
+          if ( lineRGB[v15] != pict_byte )//Uninitialized memory access
             break;
           if ( !(v15 % pitch) )
             break;
--- a/Sprites.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/Sprites.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -407,7 +407,7 @@
   memcpy(pSpriteEFrames + num_mm6_frames + num_mm7_frames, (char *)data_mm8 + 8 + mm8_frames_size, 2 * num_mm8_eframes);
 
   for (uint i = 0; i < num_mm7_frames; ++i)
-    pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]];
+    pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i]];//Uninitialized memory access
   
   for (uint i = num_mm7_frames; i < num_mm6_frames + num_mm7_frames; ++i)
     pSpritePFrames[i] = &pSpriteSFrames[pSpriteEFrames[i] + num_mm7_frames];
--- a/mm7_2.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/mm7_2.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -418,7 +418,7 @@
       if ( v22 != 255 )
         v22 &= 0x7FFFFFFFu;
       v23 = _450F55(v251 | ((v252 | ((a6b | (v22 << 8)) << 8)) << 8));
-      *(_DWORD *)v193 = v23;
+      *(_DWORD *)v193 = v23; //Invalid memory access
       v193 = (unsigned __int16 *)((char *)v193 + field_20_bits);
     }
     v193 = (unsigned __int16 *)((char *)v193 + field_20_bits * (dstPitch - dstWidth));
--- a/stru6.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/stru6.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -1459,7 +1459,7 @@
     uFadeTime -= pEventTimer->uTimeElapsed;
   }
 
-  if (uAnimLength > 0)
+  if (uAnimLength > 0) //Uninitialized memory access
   {
     v8 = 8
        * pSpriteFrameTable->pSpriteSFrames[pSpriteFrameTable->FastFindSprite("spell84")].uAnimLength
--- a/texts.cpp	Tue Jul 22 17:43:28 2014 +0600
+++ b/texts.cpp	Wed Jul 23 01:12:55 2014 +0600
@@ -150,7 +150,7 @@
 			}
 		while ( step <= 2 && !string_end);  
 
-		test_string = strtok(NULL, "\r") + 1;  //Carriage Return 0D 13
+		test_string = strtok(NULL, "\r") + 1;  //Carriage Return 0D 13 //Invalid memory access
 		}	
 
   SetSomeItemsNames();