ã¡ããã©ä»ãç§ã¯åº§ã£ãŠPVS-Studioã䜿çšããŠVirtualDubãããžã§ã¯ãããã§ãã¯ããŸããã éžæã¯ã©ã³ãã ã§ããã æãéèŠãªããšã¯ãPVS-Studioã³ãŒãã¢ãã©ã€ã¶ãŒã®éçºç¶æ³ã瀺ãããã«ãããŸããŸãªãããžã§ã¯ããå®æçã«ãã§ãã¯/ããã«ãã§ãã¯ããããšã ãšæããŸãã ãããŠãã©ã®ãããžã§ã¯ãããã¹ããããã¯ããã»ã©éèŠã§ã¯ãããŸããã ééãã¯ã©ãã«ã§ããããŸãã 2011幎ã«VirtualDubãããžã§ã¯ããæ¢ã«ãã¹ãããŸããããèå³æ·±ããã®ã¯ã»ãšãã©èŠã€ãããŸããã§ããã ã ããã2幎åŸã«ç©äºãã©ããªãããèŠãããšã«ããŸããã
VirtualDub Webãµã€ãããVirtualDub-1.10.3-src.7zã¢ãŒã«ã€ããããŠã³ããŒãããŸããã åæã«ã¯ã PVS-StudioããŒãžã§ã³5.10ã䜿çšããŸããã åæã«ã¯çŽ1æéããããŸããã®ã§ãå³å¯ã«å€æããªãã§ãã ããã 確ãã«ãç§ã¯äœããèŠéããã ãããŠãã®éã«ãæ£ããã³ãŒãã¯çããããšèããããšãã§ããŸãã VirtualDubãããžã§ã¯ãããµããŒããã人ã«ã¯ãç§ã®ã¬ããŒãã«é Œããã«ãç¬ç«ãããã§ãã¯ãè¡ããããé¡ãããŸãã ç§ãã¡ã¯åžžã«ãªãŒãã³ãœãŒã¹ã³ãã¥ããã£ã«äŒãã«è¡ã ãç»é²ããŒãå²ãåœãŠãæºåãã§ããŠããŸãã
ãŸãããšã€ããªã£ã»ãªãŒã«ãã®èšäºãç解ããŠæ±ããããé¡ããããã§ãã ååã圌ã¯ç§ã®èšäºã®1ã€ã§VirtualDubã«ã€ããŠéåžžã«çã ããã»ã©èšåããŸããã ç§ã¯ãŸã£ããæãã§ããŸããã§ããããããã€ãã®ããã°ã©ã ããã°ã ãšèšãããã¯ãããŸããã ãœãããŠã§ã¢ã®ãã°ã¯ã©ãã«ã§ããããŸãã ç§ã®ç®æšã¯ãéçã³ãŒãåæãæäŸã§ããå©ç¹ã瀺ãããšã§ãã ããã«ããããªãŒãã³ãœãŒã¹ãããžã§ã¯ãã®ä¿¡é Œæ§ãå°ãåäžããŸãã ããã¯çŽ æŽãããã
ãã¡ããã1åéãã®ãã§ãã¯ã¯ç¡å¹ã§ãã ããããæ®å¿µãªãããç§ã¯ããã«ã€ããŠäœãã§ããŸããã éçåæããŒã«ãå®æçã«äœ¿çšãããã©ããã¯ãéçºè 次第ã§ãã ç§ã¯ãéåžžã®äœ¿çšã®å©ç¹ãäœã§ãããã説æããããšããã ãã§ãã ãã®ãããã¯ã«é¢ããèå³æ·±ãã¡ã¢ã®1ã€ã¯ã Leo Tolstoyãšéçã³ãŒãåæã§ãã
ãã ãããã®èšäºã¯éçåæã䜿çšããããã®æ¹æ³è«ã§ã¯ãªãããšã©ãŒã«é¢ãããã®ã§ãã VirtualDubã§èŠã€ãã£ãæ°ããèå³æ·±ãPVS-Studioã¢ãã©ã€ã¶ãŒãèŠãŠã¿ãŸãããã
ä»®æ³ãã¹ãã©ã¯ã¿
C ++ããã°ã©ãã³ã°èšèªã§ã¯ãããªã¢ãŒãã£ãã¯ããŒã¹ã¯ã©ã¹ã®ãã¹ãã©ã¯ã¿ãä»®æ³ãšããŠå®£èšããå¿ èŠããããŸãã ããã¯ã察å¿ããåºæ¬ã¯ã©ã¹ãžã®ãã€ã³ã¿ãŒãä»ããŠã掟çã¯ã©ã¹ã®ãªããžã§ã¯ãã®æ£ããç Žæ£ãä¿èšŒããå¯äžã®æ¹æ³ã§ãã
ç§ã¯èª°ãããããç¥ã£ãŠããããšãç¥ã£ãŠããŸãã ãã ããããã¯ãã¹ãã©ã¯ã¿ä»®æ³ã®å®£èšãå¿ããããšãæ¢ããŸããã
VirtualDubã«ã¯VDDialogBaseW32ã¯ã©ã¹ããããŸãã
class VDDialogBaseW32 { .... ~VDDialogBaseW32(); .... virtual INT_PTR DlgProc(....) = 0; virtual bool PreNCDestroy(); .... }
ã芧ã®ãšãããä»®æ³é¢æ°ãå«ãŸããŠããŸãã ãã ãããã¹ãã©ã¯ã¿ã¯ä»®æ³ãšããŠå®£èšãããŠããŸããã åœç¶ã圌ã®ã¯ã©ã¹ã¯åœŒããç¶æ¿ãããŸãã ããšãã°ãVDDialogAudioFilterFormatConvConfigïŒ
class VDDialogAudioFilterFormatConvConfig : public VDDialogBaseW32 { .... };
ãªããžã§ã¯ãç Žæ£ãšã©ãŒã¯æ¬¡ã®ããã«ãªããŸãã
INT_PTR CALLBACK VDDialogBaseW32::StaticDlgProc(....) { VDDialogBaseW32 *pThis = (VDDialogBaseW32 *)GetWindowLongPtr(hwnd, DWLP_USER); .... delete pThis; .... }
PVS-Studioãçºè¡ããèŠåïŒV599ãVDDialogBaseW32ãã¯ã©ã¹ã«ã¯ä»®æ³é¢æ°ãå«ãŸããŠããŸããããã¹ãã©ã¯ã¿ã¯ä»®æ³ãã¹ãã©ã¯ã¿ãšããŠå®£èšãããŠããŸããã VirtualDub gui.cpp 997
ã芧ã®ãšãããåºæ¬ã¯ã©ã¹ãžã®ãã€ã³ã¿ãŒã䜿çšããŠãªããžã§ã¯ããç Žæ£ããŸãã ãã®ãããªãªããžã§ã¯ãã®åé€ã¯ãæªå®çŸ©ã®ããã°ã©ã ã®åäœã«ã€ãªãããŸãã
VDMPEGAudioPolyphaseFilterã¯ã©ã¹ã«ãåæ§ã®äžå¹žããããŸãã
ãããŸããªåäœã®è©³çŽ°
ä»®æ³ãã¹ãã©ã¯ã¿ã«é¢é£ãããšã©ãŒã«é¢ãã質åã¯ãããŸããã ããæ»ãããããããã¯ã¯ã·ããæäœã§ãã 以äžã«ãã®ãããªäŸã瀺ããŸãã
void AVIVideoGIFOutputStream::write(....) { { .... for(int i=0; i<palsize; ++i) dict[i].mPrevAndLastChar = (-1 << 16) + i; .... }
ããã¯ã10幎以äžã«ããã£ãŠæ£åžžã«äœ¿çšãããŠããå®å šã«ä¿¡é Œã§ããã³ãŒãã§ãããšã奜ããªã ãèšãããšãã§ããŸãã ãã ãããšã«ãããããã§ã¯ããã°ã©ã ã®äžå®ã®åäœãæ±ã£ãŠããŸãã ãã®ãããªæ§é ã«ã€ããŠèŠæ Œãèšã£ãŠããããšã¯æ¬¡ã®ãšããã§ãã
ã·ããæŒç®å<<ããã³>>ã¯ãå·Šããå³ã«ã°ã«ãŒãåããŸãã
ã·ããåŒ<<å ç®åŒ
ã·ããåŒ>>å ç®åŒ
ãªãã©ã³ãã¯æŽæ°ãŸãã¯ã¹ã³ãŒããªãã®åæåã§ããå¿ èŠããããæŽæ°ã®ããã¢ãŒã·ã§ã³ãå®è¡ãããŸãã
1.çµæã®åã¯ãææ Œããå·Šãªãã©ã³ãã®åã§ãã å³ã®ãªãã©ã³ããè² ã®å ŽåããŸãã¯ææ Œããå·Šã®ãªãã©ã³ãã®ãããé·ä»¥äžã®å Žåãåäœã¯æªå®çŸ©ã§ãã
2. E1 << E2ã®å€ã¯ãE1ãå·Šã«ã·ããããE2ãããäœçœ®ã§ãã 空ããããã¯ãŒãã§åããããŸãã E1ã«ç¬Šå·ãªãã®åãããå Žåãçµæã®å€ã¯E1 * 2 ^ E2ã§ãçµæã®åã§è¡šçŸå¯èœãªæ倧å€ããã1å€ãã¢ãžã¥ãã§ãã ãã以å€ã®å ŽåãE1ã«ç¬Šå·ä»ãã®åãšè² ã§ãªãå€ããããE1 * 2 ^ E2ãçµæã®åã§è¡šçŸã§ããå Žåããããçµæã®å€ã§ãã ãã以å€ã®å Žåãåäœã¯æªå®çŸ©ã§ãã
3. E1 >> E2ã®å€ã¯ãE1ãå³ã·ããããE2ãããäœçœ®ã§ãã E1ã«ç¬Šå·ãªãã®åãããå ŽåããŸãã¯E1ã«ç¬Šå·ä»ãã®åãšè² ã§ãªãå€ãããå Žåãçµæã®å€ã¯E1 / 2 ^ E2ã®åã®æŽæ°éšåã§ã ã E1ã«ç¬Šå·ä»ãã¿ã€ããšè² ã®å€ãããå Žåãçµæã®å€ã¯å®è£ å®çŸ©ã§ãã
ã³ãŒããæ©èœããã®ã¯éã§ãã æé©åã®ããã«æ°ããã³ã³ãã€ã©ãŸãã¯ä»ã®ããŒããã¹ã¿ãŒãããšããããã°ã©ã ã¯ãã®åäœãäºæããå€æŽããå ŽåããããŸãã ã·ããã®è©³çŽ°ãšãã³ãŒããç·šéãã䟡å€ããããã©ããã«ã€ããŠã¯ãã ãã©ãŒããç¥ããªãã§ãæ°Žã«å ¥ããªãã§ãã ãããããŒã3 ãã®èšäºãåç §ããŠãã ãã ã
以äžã¯ãPVS-Studioã¢ãã©ã€ã¶ãŒãVirtualDubãããžã§ã¯ãã§æªå®çŸ©ã®åäœãŸãã¯æªæå®ã®åäœãæ€åºããå Žæã®å®å šãªãªã¹ãã§ã ã
ã¿ã€ããã¹
static ModuleInfo *CrashGetModules(void *&ptr) { .... while(*pszHeap++); if (pszHeap[-1]=='.') period = pszHeap-1; .... }
PVS-Studio蚺æã¡ãã»ãŒãžïŒV529å¥æ°ã®ã»ãã³ãã³ ';' ãwhileãæŒç®åã®åŸã VirtualDub crash.cpp 462
ãwhileãã®åŸã®ã»ãã³ãã³ã«æ³šæããŠãã ããã ããã§ã¯ããšã©ãŒãŸãã¯ã³ãŒãã®åœ¢åŒãæ£ãããããŸããã ããã¯ãŸãã«ééãã ãšæããŸãã ã«ãŒããwhileïŒ* pszHeap ++ïŒ;ãã¯è¡æ«ã«ç§»åãããã®çµæãå€æ°ãpszHeapãã¯ç«¯æ«ãŒãã®åŸã«ã¡ã¢ãªãæããŸã ã ãifïŒpszHeap [-1] == 'ã'ïŒãããã§ãã¯ããŠãæå³ããããŸããã ã¢ãã¬ã¹pszHeap [-1]ã«ã¯åžžã«çµç«¯ãŒãããããŸãã
æååãæ±ããšãã¯ãå¥ã®ã¿ã€ããã¹ãèæ ®ããŠãã ããã
void VDBackfaceService::Execute(...., char *s) { .... if (*s == '"') { while(*s && *s != '"') ++s; } else { .... }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV637 2ã€ã®æ£å察ã®æ¡ä»¶ãçºçããŸããã 2çªç®ã®æ¡ä»¶ã¯åžžã«falseã§ãã è¡ã確èªïŒ183ã184ãVirtualDub backface.cpp 183
ãã®ã³ãŒãã¯ãåŒçšç¬Šå ã®ãã¹ãŠãã¹ãããããå¿ èŠããããŸãã å°ãªããšããããã颚ã«æããŸãã ãã ããæ¡ä»¶ïŒ* s && * sïŒ= '"'ïŒã¯ããã«falseã§ãããããããã³ãŒãã¯æ¬¡ã®ããã«ãªã£ãŠããã¯ãã§ãã
if (*s == '"') { ++s; while(*s && *s != '"') ++s; }
newæŒç®åã¯ãã¡ã¢ãªã®å²ãåœãŠã«å€±æãããšäŸå€ãã¹ããŒããŸãã
å€ãã³ãŒãã§ã¯ãå€ãã®å Žåãæ°ããæŒç®åãè¿ããããã©ããã®ãã§ãã¯ã«ééããŸãã 次ã®ããã«ãªããŸãã
int *p = new int[10]; if (!p) return false;
C ++èšèªæšæºããµããŒãããææ°ã®ã³ã³ãã€ã©ã¯ãã¡ã¢ãªå²ãåœãŠã倱æããå Žåã«äŸå€ãã¹ããŒããå¿ èŠããããŸãã ãnewãæŒç®åãäŸå€ãã¹ããŒããªãããã«ã§ããŸãããçŸåšæ€èšäžã®ã±ãŒã¹ãšã¯é¢ä¿ãããŸããã
ãããã£ãŠãïŒïŒPïŒãäžèŠã§ãããã©ããã確èªããŸãã äžè¬ã«ããã®ãããªã³ãŒãã¯ç¡å®³ã§ãã è¿œå ã®ãã§ãã¯ã å¿é ããå¿ èŠã¯ãããŸããã
ãã ããå€ãã³ãŒãã¯äžå¿«ãªçµæãæãå¯èœæ§ããããŸãã VirtualDubãããžã§ã¯ãããã®ãã©ã°ã¡ã³ããæ€èšããŠãã ããã
void HexEditor::Find(HWND hwndParent) { .... int *next = new int[nFindLength+1]; char *searchbuffer = new char[65536]; char *revstring = new char[nFindLength]; .... if (!next || !searchbuffer || !revstring) { delete[] next; delete[] searchbuffer; delete[] revstring; return; } .... }
PV-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV668ã¡ã¢ãªããæ°ãããæŒç®åã䜿çšããŠå²ãåœãŠããããããã次ã®ããã€ã³ã¿ãŒãnullã«å¯ŸããŠãã¹ãããŠãæå³ããããŸããã ã¡ã¢ãªå²ãåœãŠãšã©ãŒã®å ŽåãäŸå€ãçæãããŸãã VirtualDub hexviewer.cpp 2012
æååãchar * revstring = new char [nFindLength];ãã§äŸå€ãçºçãããšãã¡ã¢ãªãªãŒã¯ãçºçããŸãã delete []ã¹ããŒãã¡ã³ãã¯åŒã³åºãããŸããã é倧ãªééãã§ã¯ãããŸããããããã«ã€ããŠèšåãã䟡å€ã¯ãããŸãã
ããã§ã¯ãVirtualDubã§ãnewãæŒç®åãåŒã³åºããåŸã«ãã€ã³ã¿ãŒããã§ãã¯ããããã¹ãŠã®å Žæããªã¹ããããŸãã
ç Žå£ããããªããžã§ã¯ããžã®ãªã³ã¯
vdlist_iterator& operator--(int) { vdlist_iterator tmp(*this); mp = mp->mListNodePrev; return tmp; }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV558é¢æ°ã¯ãäžæããŒã«ã«ãªããžã§ã¯ããžã®åç §ãè¿ããŸãïŒtmpã VirtualDub vdstl.h 460
é¢æ°ãæ£ããå®è£ ãããŠããŸããã ããŒã«ã«ã®ãtmpããªããžã§ã¯ããžã®åç §ãè¿ããŸãã é¢æ°ãçµäºãããšããã§ã«ç Žæ£ãããŸãã ãã®ãªã³ã¯ã䜿çšãããšãæªå®çŸ©ã®åäœãçºçããŸãã
ãšããã§ãè¿ãã«ãã++æŒç®åã¯æ£ããå®è£ ãããŠããŸãã
æåã«äœ¿çšãã次ã«ãã§ãã¯ããŸã
ããŸããŸãªããã°ã©ã ã§ã¯ããã€ã³ã¿ãŒãæåã«éæ¥åç §ããããšãã«ãšã©ãŒãçºçããããšãå€ãããã®å Žåã®ã¿NULLãšæ¯èŒãããŸãã NULLãã€ã³ã¿ãŒã®ç䟡æ§ã¯å¶çºçãªãŸããªç¶æ³ã§ããããããã®ãããªãšã©ãŒã¯éåžžã«é·ãéçŸããŸããã ãããã®æ¬ ç¹ã¯VirtualDubã³ãŒãã«ååšããŸãã äŸïŒ
LRESULT YUVCodec::DecompressGetFormat(BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) { BITMAPINFOHEADER *bmihInput = &lpbiInput->bmiHeader; BITMAPINFOHEADER *bmihOutput = &lpbiOutput->bmiHeader; LRESULT res; if (!lpbiOutput) return sizeof(BITMAPINFOHEADER); .... }
PVS-Studio蚺æã¡ãã»ãŒãžïŒV595 nullptrã«å¯ŸããŠæ€èšŒãããåã«ããlpbiOutputããã€ã³ã¿ãŒã䜿çšãããŸããã è¡ã確èªããŠãã ããïŒ82ã85ãVirtualDub yuvcodec.cpp 82
æåã«ãlpbiOutputãã€ã³ã¿ãŒãéåç §ãããŸãã 次ã«ããifïŒïŒLpbiOutputïŒãããã§ãã¯ãããŸãã ãã®ãããªãšã©ãŒã¯éåžžããªãã¡ã¯ã¿ãªã³ã°äžã«çºçããŸãã æ°ããã³ãŒãã¯ãå¿ èŠãªãã§ãã¯ã®åã«æ¿å ¥ãããŸãã äžèšã®ã³ãŒããä¿®æ£ããã«ã¯ãã¢ã¯ã·ã§ã³ã®ã·ãŒã±ã³ã¹ãå€æŽããå¿ èŠããããŸãã
LRESULT YUVCodec::DecompressGetFormat(BITMAPINFO *lpbiInput, BITMAPINFO *lpbiOutput) { if (!lpbiOutput) return sizeof(BITMAPINFOHEADER); BITMAPINFOHEADER *bmihInput = &lpbiInput->bmiHeader; BITMAPINFOHEADER *bmihOutput = &lpbiOutput->bmiHeader; LRESULT res; .... }
ã¢ãã©ã€ã¶ãŒãV595èŠåãçºè¡ããä»ã®å Žæã¯ã ããã«ãªã¹ããããŠããŸã ã
HRESULTã¿ã€ãã䜿çšãã
VDPosition AVIReadTunnelStream::TimeToPosition(VDTime timeInUs) { AVISTREAMINFO asi; if (AVIStreamInfo(pas, &asi, sizeof asi)) return 0; return VDRoundToInt64(timeInUs * (double)asi.dwRate / (double)asi.dwScale * (1.0 / 1000000.0)); }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV545ãã®ãããªãifãæŒç®åã®æ¡ä»¶åŒã¯ãHRESULTåã®å€ãAVIStreamInfoAïŒpasãïŒasiãsizeof asiïŒãã«å¯ŸããŠæ£ãããããŸããã 代ããã«SUCCEEDEDãŸãã¯FAILEDãã¯ãã䜿çšããå¿ èŠããããŸãã VirtualDub avireadhandlertunnelw32.cpp 230
AVIStreamInfoïŒïŒé¢æ°ã¯ãHRESULTåã®å€ãè¿ããŸãã ãã®ã¿ã€ãã¯ãboolããšããŠè§£éã§ããŸããã HRESULTåã®å€æ°ã«æ ŒçŽãããŠããæ å ±ã¯ãããªãè€éãªæ§é ãæã£ãŠããŸãã HRESULTå€ã確èªããã«ã¯ããWinError.hãã§å®£èšãããŠããSUCCEEDEDãŸãã¯FAILEDãã¯ãã䜿çšããå¿ èŠããããŸãã ãããã®ãã¯ãã®ä»çµã¿ã¯æ¬¡ã®ãšããã§ãã
#define FAILED(hr) (((HRESULT)(hr)) < 0) #define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
æ£ããã³ãŒãã¯æ¬¡ã®ãšããã§ãã
if (FAILED(AVIStreamInfo(pas, &asi, sizeof asi)))
PVS-Studioã¯ã次ã®è¡ã«ãåæ§ã®èŠåã衚瀺ããŸãã
- avireadhandlertunnelw32.cpp 238
- avireadhandlertunnelw32.cpp 335
- inputfileavi.cpp 440
- context_d3d11.cpp 959
ããžãã¯ãã³ããŒ
æ°åã䜿çšããŠæååã®é·ããèšå®ããããšã¯ãå§ãã§ããŸããã æåãæ°ãããšãã«ééããç¯ãã®ã¯éåžžã«ç°¡åã§ãã äŸïŒ
bool VDOpenGLBinding::Attach(....) { .... if (!memcmp(start, "GL_EXT_blend_subtract", 20)) .... }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV512ãmemcmpãé¢æ°ã®åŒã³åºãã¯ããããã¡ãŒãGL_EXT_blend_subtractãã®ã¢ã³ããŒãããŒãåŒãèµ·ãããŸãã ãªã¶opengl.cpp 393
æååãGL_EXT_blend_subtractãã®é·ãã¯20æåã§ã¯ãªãã21æåã§ãã ãšã©ãŒã¯é倧ã§ã¯ãããŸããã å®éã«ã¯ãè¡çªã¯çºçããŸããã ãã ãããã®ãããªããžãã¯ãã³ããŒã¯é¿ããŠãã ããã æååã®é·ããã«ãŠã³ãããã«ã¯ãç¹å¥ãªãã¯ãã䜿çšããããšããå§ãããŸãã äŸïŒ
#define LiteralStrLen(S) (sizeof(S) / sizeof(S[0]) - 1)
C ++ã§ã¯ãããå®å šãªãã³ãã¬ãŒãé¢æ°ãäœæã§ããŸãã
template <typename T, size_t N> char (&ArraySizeHelper(T (&array)[N]))[N]; template <typename T, size_t N> size_t LiteralStrLen(T (&array)[N]) { return sizeof(ArraySizeHelper(array)) - 1; }
2çªç®ã®ãªãã·ã§ã³ã®å©ç¹ã¯ãåçŽãªãã€ã³ã¿ãŒã誀ã£ãŠåŒæ°ãšããŠæž¡ãããšãã§ããªãããšã§ãã ãã®ææ³ã«ã€ããŠã¯ãèšäºã PVS-Studio vs Chromium ãã§è©³ãã説æãããŠããŸãã
絶察ãã¹
VDDbgHelpDynamicLoaderW32::VDDbgHelpDynamicLoaderW32() { hmodDbgHelp = LoadLibrary( "c:\\program files\\debugging tools for windows\\dbghelp"); if (!hmodDbgHelp) { hmodDbgHelp = LoadLibrary("c:\\program files (x86)\\...... .... }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV631ãLoadLibraryAãé¢æ°åŒã³åºãã®æ€æ»ãæ€èšããŠãã ããã ãã¡ã€ã«ãŸãã¯ãã£ã¬ã¯ããªãžã®çµ¶å¯Ÿãã¹ãå®çŸ©ããããšã¯ãã¹ã¿ã€ã«ãæªããšèŠãªãããŸãã VirtualDub leaks.cpp 67ã69
ãã®ã³ãŒããæªãçç±ã¯æããã ãšæããŸãã ãã¡ãããã³ãŒãã¯ãããã°ã«é¢é£ä»ããããŠããããšã³ããŠãŒã¶ãŒã«äœããã®åœ¢ã§æªåœ±é¿ãäžããããšã¯ã»ãšãã©ãããŸããã ãããããšã«ãããProgram Filesãžã®æ£ãããã¹ãååŸããæ¹ãè¯ãã§ãããã
ç¡å¹ãªåŒæ°
sint64 rva; void tool_lookup(....) { .... printf("%08I64x %s + %x [%s:%d]\n", addr, sym->name, addr-sym->rva, fn, line); .... }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV576 Incorrect formatã 'printf'é¢æ°ã®4çªç®ã®å®åŒæ°ã確èªããããšãæ€èšããŠãã ããã åŒæ°ã¯32ããã以äžã§ãããšäºæ³ãããŸãã ãããlookup.cpp 56
å€æ° 'rva'ã¯64ãããåã§ãã ããã¯ã8ãã€ããã¹ã¿ãã¯ã«ããã·ã¥ãããããšãæå³ããŸãã printfïŒïŒé¢æ°ã¯ã å¯å€åã®åŒæ°ãæã€é¢æ°ã§ãã åŠçããããŒã¿ã®ã¿ã€ãã¯ããã©ãŒãããæååã䜿çšããŠæå®ãããŸãã ãã®å Žåãå€æ° 'rva'ã¯32ãããå€æ°ïŒ "ïŒ x"ïŒãšããŠåŠçãããŸãã
ãã®ãšã©ãŒã倱æã«ã€ãªãããã©ããã¯ãã³ã³ãã€ã©ãåŒæ°ã®è»¢éãæŽçããæ¹æ³ãšãã©ãããã©ãŒã ã®ããã深床ã«äŸåããŸãã ããšãã°ã Win64ã§ã¯ããã¹ãŠã®æŽæ°åãæåã«64ãããåã«ãã£ã¹ããããŠãããã¹ã¿ãã¯ã«ããã·ã¥ãããŸãã å€æ°ãå¿ èŠä»¥äžã«ã¹ã¿ãã¯äžã®ã¹ããŒã¹ãå æãããšããåé¡ã¯ããã§ã¯ãããŸããã
ãã ããå€æ° 'rva'ãINT_MAXãã倧ããå€ãæ ŒçŽããå Žåããã®å€ã¯ãšã«ããæ£ããå°å·ãããŸããã
ã¢ãã©ã€ã¶ãŒã¯åæ§ã®èŠåãããã«è¡šç€ºããŸãïŒ
- dubstatus.cpp 360
- lookup.cpp 58
ééã£ãæ¯èŒ
void VDVideoCompressorVCM::GetState(vdfastvector<uint8>& data) { DWORD res; .... res = ICGetState(hic, data.data(), size); .... if (res < 0) throw MyICError("Video compression", res); }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV547åŒ 'res <0'ã¯åžžã«falseã§ãã 笊å·ãªãã®åã®å€ã0æªæºã«ãªãããšã¯ãããŸãããRizaw32videocodecpack.cpp 828
å€æ° 'res'ã«ã¯ã眲åãããŠããªãDWORDåããããŸãã ããã¯ãåŒãres <0ããåžžã«ãfalseãã«çããããšãæå³ããŸãã
åæ§ã®ãã§ãã¯ã¯ãã¡ãã§ãïŒw32videocodec.cpp 284ã
å¥ã®åæ§ã®ãšã©ãŒãæ€èšããŠãã ããã
#define ICERR_CUSTOM -400L static const char *GetVCMErrorString(uint32 icErr) { .... if (icErr <= ICERR_CUSTOM) err = "A codec-specific error occurred."; .... }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV605åŒicErr <=-400Lã®æ€èšŒãæ€èšããŠãã ããã 笊å·ãªãã®å€ã¯ãæ°å€-400ãšæ¯èŒãããŸãã ã·ã¹ãã error_win32.cpp 54
å€æ°ãicErrãã®ã¿ã€ãã¯ãunsignedãã§ãã ãããã£ãŠãæ¯èŒã®åã«ãæ°å€ã-400ãã¯æé»çã«ã笊å·ãªããã«å€æãããŸãã å€ã-400ãã¯4294966896ã«ãªããŸãããããã£ãŠãæ¯èŒïŒicErr <= -400ïŒã¯ïŒicErr <= 4294966896ïŒãšåçã§ãã ã©ããããããã¯ããã°ã©ããæãã§ããããšã§ã¯ãããŸããã
ãã®ä»ã®å¥åŠãª
void AVIOutputFile::finalize() { .... if (stream.mChunkCount && hdr.dwScale && stream.mChunkCount) .... }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV501ã&&ãæŒç®åã®å·Šå³ã«åããµãåŒãstream.mChunkCountãããããŸãã VirtualDub avioutputfile.cpp 761
å€æ° 'stream.mChunkCount'ã¯2åãã§ãã¯ãããŸãã 1ã€ã®ãã§ãã¯ãäžèŠã§ããããä»ã®ãã§ãã¯ãå¿ããŸããã
void VDVideoCompressorVCM::Start(const void *inputFormat, uint32 inputFormatSize, const void *outputFormat, uint32 outputFormatSize, const VDFraction& frameRate, VDPosition frameCount) { this->hic = hic; .... }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV570ãthis-> hicãå€æ°ã¯ããèªäœã«å²ãåœãŠãããŸãã ãªã¶w32videocodecpack.cpp 253
void VDDialogAudioConversionW32::RecomputeBandwidth() { .... if (IsDlgButtonChecked(mhdlg, IDC_PRECISION_NOCHANGE)) { if (mbSourcePrecisionKnown && mbSource16Bit) bps *= 2; else bps = 0; } if (IsDlgButtonChecked(mhdlg, IDC_PRECISION_16BIT)) bps *= 2; .... }
PVS-Studioã«ãã£ãŠçºè¡ããã蚺æã¡ãã»ãŒãžïŒV646ã¢ããªã±ãŒã·ã§ã³ã®ããžãã¯ã®æ€æ»ãæ€èšããŠãã ããã ãelseãããŒã¯ãŒããæ¬ èœããŠããå¯èœæ§ããããŸãã VirtualDub optdlg.cpp 120
ã³ãŒããæ£ãããã©ãŒããããããŠããªãå¯èœæ§ããããŸãã ãŸãã¯ãããŒã¯ãŒããelseããå¿ããããŠããå¯èœæ§ããããŸãã
bool VDCaptureDriverScreen::Init(VDGUIHandle hParent) { .... mbAudioHardwarePresent = false; mbAudioHardwarePresent = true; .... }
PVS-Studioãçºè¡ãã蚺æã¡ãã»ãŒãžïŒV519 'mbAudioHardwarePresent'å€æ°ã«ã¯ãå€ãé£ç¶ããŠ2åå²ãåœãŠãããŸãã ããããããã¯ééãã§ãã è¡ã確èªããŠãã ããïŒ274ã275ãVDCapture cap_screen.cpp 275
ãããã«
ã芧ã®ããã«ãäžåºŠã ãå®è¡ãããšããŠããéçåæã¯æçšã§ãã ããããå®æçã«å®è¡ããæ¹ãã¯ããã«äŸ¿å©ã§ãã çµå±ã®ãšãããã³ã³ãã€ã©ã®èŠåïŒèŠåïŒãããã°ã©ããŒã¯ãªãªãŒã¹åã«2å以äžå«ãŸããŠããŸããããããã¯åžžã«äœ¿çšããŠããŸãã åãç¶æ³ãéçåæããŒã«ã«ããããŸãã åžžã«äœ¿çšããããšã«ããããšã©ãŒããã°ããä¿®æ£ã§ããŸãã PVS-Studioã¯ãããèå³æ·±ãèŠåãçæããã³ã³ãã€ã©ã®äžçš®ã®ã¢ããªã³ãšèŠãªãããšãã§ããŸãã æé©ãªãªãã·ã§ã³ã¯ã å¢åã³ãŒãåæã䜿çšããããšã§ãã å€æŽããããã¡ã€ã«ãã³ã³ãã€ã«ãããšãããã«æ°ãããšã©ãŒãèŠã€ãããŸãã