diff --git a/src/media/video/video_scaler.cpp b/src/media/video/video_scaler.cpp
index 0d45fd94bb9f212e8a41b04e59f99fc7957cb306..ae8ab014ca28a34862bdd5853767d2fea65b39a5 100644
--- a/src/media/video/video_scaler.cpp
+++ b/src/media/video/video_scaler.cpp
@@ -107,8 +107,11 @@ VideoScaler::scale_and_pad(const VideoFrame& input, VideoFrame& output,
     }
 
     // buffer overflow checks
-    assert(xoff + dest_width <= (unsigned)output_frame->width);
-    assert(yoff + dest_height <= (unsigned)output_frame->height);
+    if ((xoff + dest_width > (unsigned)output_frame->width)
+        || (yoff + dest_height > (unsigned)output_frame->height)) {
+        JAMI_ERR("Unable to scale video");
+        return;
+    }
 
     ctx_ = sws_getCachedContext(ctx_,
                                 input_frame->width,