Advertisement
PVS-StudioWarnings

PVS-Studio warning V575 for MTASA

Nov 24th, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. void CDirect3DData::GetTransform (
  2.   D3DTRANSFORMSTATETYPE dwRequestedMatrix,
  3.   D3DMATRIX * pMatrixOut)
  4. {
  5.   switch ( dwRequestedMatrix )
  6.   {
  7.     case D3DTS_VIEW:
  8.       memcpy (pMatrixOut, &m_mViewMatrix, sizeof(D3DMATRIX));
  9.       break;
  10.     case D3DTS_PROJECTION:
  11.       memcpy (pMatrixOut, &m_mProjMatrix, sizeof(D3DMATRIX));
  12.       break;
  13.     case D3DTS_WORLD:
  14.       memcpy (pMatrixOut, &m_mWorldMatrix, sizeof(D3DMATRIX));
  15.       break;
  16.     default:
  17.       // Zero out the structure for the user.
  18.       memcpy (pMatrixOut, 0, sizeof(D3DMATRIX));   <<<<<<<<<<
  19.       break;
  20.   }
  21.   ....
  22. }
  23.  
  24. A Copy-Paste error. Most likely this is what should be written here: memset(pMatrixOut, 0, sizeof(D3DMATRIX));.
  25.  
  26. This suspicious code was found in MTASA project by PVS-Studio static code analyzer.
  27. Warning message is:
  28. V575 The null pointer is passed into 'memcpy' function. Inspect the second argument. cdirect3ddata.cpp 80
  29.  
  30. PVS-Studio is a static analyzer for detecting bugs in the source code of applications written in C, C++, C++11, C++/CX. Site: http://www.viva64.com/en/pvs-studio/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement