Статический анализ Си++ кода

  • Published on
    25-May-2015

  • View
    396

  • Download
    3

Embed Size (px)

DESCRIPTION

. .

Transcript

<ul><li> 1. ++ <br /><br />..-.., <br /><br />E-mail: karpov@viva64.com<br /></li></ul> <p> 2. <br /> .<br /> .<br /> 3. - !<br /> ;<br /> - , ;<br /> PVS-Studio.<br /> 4. &amp; !<br />ReturntoCastleWolfenstein - , , idSoftware. GPL .<br />#define SVF_CASTAI0x00000010<br />if ( !ent-&gt;r.svFlags&amp; SVF_CASTAI )<br />if ( ! (ent-&gt;r.svFlags &amp; SVF_CASTAI) )<br /> 5. &amp;&amp; &amp;<br />Stickies- , .<br />#define REO_INPLACEACTIVE(0x02000000L)<br />#define REO_OPEN (0x04000000L)<br />if (reObj.dwFlags&amp;&amp; REO_INPLACEACTIVE)<br />m_pRichEditOle-&gt;InPlaceDeactivate();<br />if(reObj.dwFlags&amp;&amp; REO_OPEN)<br />hr = reObj.poleobj-&gt;Close(OLECLOSE_NOSAVE);<br /> 6. Undefined behavior<br />Miranda IM (Miranda Instant Messenger) - Microsoft Windows.<br />while (*(n = ++s + strspn(s, EZXML_WS)) &amp;&amp; *n != '&gt;') {<br /> 7. delete <br />Chromium - - , Google. Chromium GoogleChrome.<br />auto_ptr child_array(new VARIANT[child_count]);<br /> auto_ptr . auto_ptr :<br />~auto_ptr() {<br />delete _Myptr;<br />}<br /> , , boost::scoped_array.<br /> 8. <br />WinDjView - DjVu.<br />inline boolIsValidChar(int c)<br />{<br />return c == 0x9 || 0xA || c == 0xD || c &gt;= 0x20 &amp;&amp; c = 0xE000 &amp;&amp; c = 0x10000 &amp;&amp; c GetUp(-1) = t;<br />else<br />v-&gt;Pop(1);<br />v-&gt;Pop(1); - <br /> 10. <br />FCE Ultra Nintendo Entertainment System<br />intiNesSaveAs(char* name)<br />{<br />...<br />fp = fopen(name,"wb");<br />int x = 0;<br />if (!fp)<br />int x = 1;<br />...<br />}<br /> 11. char unsigned char<br />// check each line for illegal utf8 sequences.<br />// If one is found, we treatthe file as ASCII,<br />// otherwise we assumean UTF8 file.<br />char * utf8CheckBuf = lineptr;<br />while ((bUTF8)&amp;&amp;(*utf8CheckBuf))<br />{<br />if ((*utf8CheckBuf == 0xC0)||<br />(*utf8CheckBuf == 0xC1)||<br />(*utf8CheckBuf &gt;= 0xF5))<br />{<br />bUTF8 = false;<br /> break;<br />}<br />TortoiseSVN Subversion, Windows.<br /> 12. <br />oCell._luminance = uint16(0.2220f*iPixel._red +<br />0.7067f*iPixel._blue +<br />0.0713f*iPixel._green);<br />....<br />oCell._luminance = 2220*iPixel._red +<br />7067*iPixel._blue +<br />0713*iPixel._green;<br />eLynx Image Processing SDK and Lab<br /> 13. <br />Lugaru , WolfireGames.<br />static inti,j,k,l,m;<br />...<br />for(j=0; j...<br />for(i=0; i...<br />for(j=0;jif(joints[j].locked)freely=0;<br />}<br />...<br />}<br />...<br />}<br /> 14. <br />LAME - MP3. <br />#define SBMAX_l22<br />int l[1+SBMAX_l];<br /> for (r0 = 0; r0 &lt; 16; r0++) {<br />...<br />for (r1 = 0; r1 &lt; 8; r1++) {<br />int a2 = gfc-&gt;scalefac_band.l[r0 + r1 + 2];<br /> 15. * ++<br />eMule - ED2K. <br />STDMETHODIMP CCustomAutoComplete::Next(...,<br />ULONG *pceltFetched)<br />{<br />...<br />if (pceltFetched != NULL)<br />*pceltFetched++;<br />...<br />}<br />(*pceltFetched)++;<br /> 16. <br />WinMerge .<br />BUFFERTYPE m_nBufferType[2];<br />...<br />// Handle unnamed buffers<br />if ((m_nBufferType[nBuffer] == BUFFER_UNNAMED) ||<br />(m_nBufferType[nBuffer] == BUFFER_UNNAMED))<br />nSaveErrorCode = SAVE_NO_FILENAME;<br /> , :<br />(m_nBufferType[0] == BUFFER_UNNAMED)||<br />(m_nBufferType[1] == BUFFER_UNNAMED)<br /> 17. <br />void lNormalizeVector_32f_P3IM(..., Ipp32s* mask, ...) {<br />Ipp32si;<br />Ipp32fnorm;<br />for(i=0; iif(mask dgFloat32(0.0f)) ? dgFloat32(1.0f) : dgFloat32(-1.0f);<br /> ?: , *.<br /> 21. , <br />if (m_szPassword != NULL)<br />{<br />if (m_szPassword != '0')<br />{<br /> Ultimate TCP/IP<br />if (*m_szPassword != '0')<br />bleeding = 0;<br />bleedx = 0,bleedy;<br />direction = 0;<br />Lugaru<br />bleedx = 0;<br />bleedy = 0;<br /> 22. , <br />if((t=(char *)realloc(<br />next-&gt;name, strlen(name+1))))<br />FCE Ultra<br />if((t=(char *)realloc(<br />next-&gt;name, strlen(name)+1)))<br />minX=max(0,minX+mcLeftStart-2);<br />minY=max(0,minY+mcTopStart-2);<br />maxX=min((int)width,maxX+mcRightEnd-1);<br />maxY=min((int)height,maxX+mcBottomEnd-1);<br />minX=max(0,minX+mcLeftStart-2);<br />minY=max(0,minY+mcTopStart-2);<br />maxX=min((int)width,maxX+mcRightEnd-1);<br />maxY=min((int)height,maxY+mcBottomEnd-1);<br /> 23. <br /> , :<br />ZeroMemory;<br />memset;<br />memcpy;<br />memcmp;<br /><br /> 24. <br />ID_INLINE mat3_t::mat3_t( float src[3][3] )<br />{<br />memcpy( mat, src, sizeof( src ) );<br />}<br />Return to Castle Wolfenstein<br />ID_INLINE mat3_t::mat3_t( float (&amp;src)[3][3] )<br />{<br />memcpy( mat, src, sizeof( src ) );<br />}<br />itemInfo_t *itemInfo;<br />memset( itemInfo, 0, sizeof( &amp;itemInfo ) );<br />memset( itemInfo, 0, sizeof( *itemInfo ) );<br /> 25. <br />CxImage - .<br />memset(tcmpt-&gt;stepsizes, 0,<br />sizeof(tcmpt-&gt;numstepsizes * sizeof(uint_fast16_t)));<br />memset(tcmpt-&gt;stepsizes, 0,<br />tcmpt-&gt;numstepsizes * sizeof(uint_fast16_t));<br /> 26. <br /> 64- :<br />dgInt32 faceOffsetHitogram[256];<br />dgSubMesh* mainSegmenst[256];<br />memset (faceOffsetHitogram, 0, sizeof (faceOffsetHitogram));<br />memset (mainSegmenst, 0, sizeof (faceOffsetHitogram));<br /> . Win64 dgInt32 mainSegmenst.<br /> 27. <br />#define CONT_MAP_MAX 50<br />int _iContMap[CONT_MAP_MAX];<br />...<br />memset(_iContMap, -1, CONT_MAP_MAX);<br />memset(_iContMap, -1, CONT_MAP_MAX * sizeof(int));<br /> 28. <br />OGRE (Object-OrientedGraphicsRenderingEngine) - - , C++.<br />Real w, x, y, z;<br />...<br />inline Quaternion(Real* valptr)<br />{<br />memcpy(&amp;w, valptr, sizeof(Real)*4);<br />}<br />, .<br /> !<br /> 29. <br /> 30. - -?<br /> , ;<br /> (undefined behavior, );<br /> -:<br /> ;<br />.<br /> 31. -, <br />FennecMediaProject- - .<br />OPENFILENAMElofn;<br />...<br />lofn.lpstrFilter = uni("All Files (*.*)0*.*");<br />lofn.lpstrFilter = uni("All Files (*.*)0*.*0");<br /> 32. -, <br />static INT_PTR CALLBACK DlgProcTrayOpts(...)<br />{<br />...<br />EnableWindow(GetDlgItem(hwndDlg,IDC_PRIMARYSTATUS),TRUE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIMESPIN),FALSE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLETIME),FALSE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSPRIMARY),FALSE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_ALWAYSPRIMARY),FALSE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_CYCLE),FALSE);<br />EnableWindow(GetDlgItem(hwndDlg,IDC_MULTITRAY),FALSE);<br />...<br />}<br /> 33. PVS-Studio?<br /></p> <ul><li> : http://www.viva64.com/ru/pvs-studio/ </li></ul> <p> 34. : http://www.viva64.com/ru/pvs-studio-download/ 35. : http://www.viva64.com/ru/d/PVS-Studio - , C/C++/C++0x.<br />PVS-Studio VisualStudio 2005/2008/2010.<br /> 36. ?<br /> :<br /><br />..-.., <br /><br />: http://www.viva64.com/ru/<br />E-mail: karpov@viva64.com<br />.: +7 (4872) 38-59-95 (GMT + 03:00)<br />Twitter: https://twitter.com/Code_Analysis<br /></p>