mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
videoframe-audiolevel: Fix possible division by zero
In update_rms_from_buffer(), division by "frames" wasn't checking whether "frames" is zero. CID 1341519. https://bugzilla.gnome.org/show_bug.cgi?id=759443
This commit is contained in:
parent
0b5387b96c
commit
dc9cf44697
1 changed files with 4 additions and 2 deletions
|
@ -495,9 +495,11 @@ update_rms_from_buffer (GstVideoFrameAudioLevel * self, GstBuffer * inbuf)
|
|||
g_value_init (&v, G_TYPE_DOUBLE);
|
||||
g_value_init (&va, G_TYPE_VALUE_ARRAY);
|
||||
for (i = 0; i < channels; i++) {
|
||||
gdouble rms = sqrt (self->CS[i] / frames);
|
||||
if (frames == 0 && self->CS[i] == 0) {
|
||||
gdouble rms;
|
||||
if (frames == 0 || self->CS[i] == 0) {
|
||||
rms = 0; /* empty buffer */
|
||||
} else {
|
||||
rms = sqrt (self->CS[i] / frames);
|
||||
}
|
||||
self->CS[i] = 0.0;
|
||||
g_value_set_double (&v, rms);
|
||||
|
|
Loading…
Reference in a new issue