From e92894e4ab344f8c0fa8ea69c231eaaee6b83ac8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Fri, 1 Jul 2016 12:20:14 +0100 Subject: [PATCH] codecparsers: jpeg2000: don't allow 0 value for array access with i-1 --- gst-libs/gst/codecparsers/gstjpeg2000sampling.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gst-libs/gst/codecparsers/gstjpeg2000sampling.c b/gst-libs/gst/codecparsers/gstjpeg2000sampling.c index edf885f7b5..dba1c50fda 100644 --- a/gst-libs/gst/codecparsers/gstjpeg2000sampling.c +++ b/gst-libs/gst/codecparsers/gstjpeg2000sampling.c @@ -104,8 +104,10 @@ GstJPEG2000Colorspace gst_jpeg2000_colorspace_from_string (const gchar * colorspace_string) { GstJPEG2000Colorspace i; + g_return_val_if_fail (colorspace_string != NULL, GST_JPEG2000_COLORSPACE_NONE); + for (i = 0; i < G_N_ELEMENTS (gst_jpeg2000_colorspace_strings); ++i) { if (!g_strcmp0 (colorspace_string, gst_jpeg2000_colorspace_strings[i])) return (i + 1); @@ -117,7 +119,8 @@ gst_jpeg2000_colorspace_from_string (const gchar * colorspace_string) const gchar * gst_jpeg2000_colorspace_to_string (GstJPEG2000Colorspace colorspace) { - g_return_val_if_fail (colorspace >= 0 + g_return_val_if_fail (colorspace > GST_JPEG2000_COLORSPACE_NONE && colorspace <= G_N_ELEMENTS (gst_jpeg2000_colorspace_strings), NULL); + return gst_jpeg2000_colorspace_strings[colorspace - 1]; }