qt: fix crash when saving RTP audio

The UI crashes when saving a RTP due to a division by zero.
To reproduce: open a RTP capture file, Telephony->RTP->RTP Streams,
then choose a stream, ANALYZE, SAVE, AUDIO, choose a path.

Bug: 12211
Change-Id: I51d61eb6797fc82c1b03254abaec839d3a1e281d
Reviewed-on: https://code.wireshark.org/review/15621
Reviewed-by: Michael Mann <mmann78@netscape.net>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Dario Lombardo 2016-05-30 16:34:03 +02:00 committed by Anders Broman
parent ccb936eca5
commit 057d8a80f0
1 changed files with 2 additions and 2 deletions

View File

@ -1214,8 +1214,8 @@ void RtpAnalysisDialog::saveAudio(RtpAnalysisDialog::StreamDirection direction)
if (stop_flag) {
break;
}
int fwd_pct = fwd_tempfile_->pos() * 100 / fwd_tempfile_->size();
int rev_pct = rev_tempfile_->pos() * 100 / rev_tempfile_->size();
int fwd_pct = (fwd_tempfile_->size() > 0 ? fwd_tempfile_->pos() * 100 / fwd_tempfile_->size() : 0);
int rev_pct = (rev_tempfile_->size() > 0 ? rev_tempfile_->pos() * 100 / rev_tempfile_->size() : 0);
ui->progressFrame->setValue(qMin(fwd_pct, rev_pct));
if (f_write_silence > 0) {