summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2021-05-22 01:53:43 +0100
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>2021-06-02 12:39:53 +0000
commitcc1a7e2c4d10ab118d635a9db163440bc9d96dd0 (patch)
tree399f32ad643394d961926eabedc3c54d37104841
parentcaae1a632aac657dc68bfc153580718353716e51 (diff)
downloadgstreamer-plugins-ugly-cc1a7e2c4d10ab118d635a9db163440bc9d96dd0.tar.gz
Use g_memdup2() where available and add fallback for older GLib versions
- x264 encoder bitrate profile manager: alloc size is based on existing allocation - asfdemux: change length var to 64-bit and check for G_MAXUINT - realmedia: opaque_data_len is read from 32 bits and then only subtracted upon. g_memdup() is deprecated since GLib 2.68 and we want to avoid deprecation warnings with recent versions of GLib. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-ugly/-/merge_requests/83>
-rw-r--r--ext/x264/gstencoderbitrateprofilemanager.c7
-rw-r--r--gst/asfdemux/gstasfdemux.c7
-rw-r--r--gst/realmedia/rtspreal.c4
-rw-r--r--meson.build6
4 files changed, 17 insertions, 7 deletions
diff --git a/ext/x264/gstencoderbitrateprofilemanager.c b/ext/x264/gstencoderbitrateprofilemanager.c
index 5ef83eec..ed2371e1 100644
--- a/ext/x264/gstencoderbitrateprofilemanager.c
+++ b/ext/x264/gstencoderbitrateprofilemanager.c
@@ -18,6 +18,9 @@
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
#include "gstencoderbitrateprofilemanager.h"
@@ -95,7 +98,7 @@ gst_encoder_bitrate_profile_manager_add_profile (GstEncoderBitrateProfileManager
* self, const gchar * profile_name,
const GstEncoderBitrateTargetForPixelsMap * map)
{
- gint n_vals;
+ guint n_vals;
GstEncoderBitrateProfile *profile;
for (n_vals = 0;
@@ -107,7 +110,7 @@ gst_encoder_bitrate_profile_manager_add_profile (GstEncoderBitrateProfileManager
profile->name = g_strdup (profile_name);
profile->n_vals = n_vals;
profile->map
- = g_memdup (map, sizeof (GstEncoderBitrateTargetForPixelsMap) * n_vals);
+ = g_memdup2 (map, sizeof (GstEncoderBitrateTargetForPixelsMap) * n_vals);
self->profiles = g_list_prepend (self->profiles, profile);
}
diff --git a/gst/asfdemux/gstasfdemux.c b/gst/asfdemux/gstasfdemux.c
index 2cf236c9..0c8dc848 100644
--- a/gst/asfdemux/gstasfdemux.c
+++ b/gst/asfdemux/gstasfdemux.c
@@ -2458,15 +2458,18 @@ gst_asf_demux_get_buffer (GstBuffer ** p_buf, guint num_bytes_to_read,
}
static gboolean
-gst_asf_demux_get_bytes (guint8 ** p_buf, guint num_bytes_to_read,
+gst_asf_demux_get_bytes (guint8 ** p_buf, guint64 num_bytes_to_read,
guint8 ** p_data, guint64 * p_size)
{
*p_buf = NULL;
+ if (num_bytes_to_read >= G_MAXUINT)
+ return FALSE;
+
if (*p_size < num_bytes_to_read)
return FALSE;
- *p_buf = g_memdup (*p_data, num_bytes_to_read);
+ *p_buf = g_memdup2 (*p_data, num_bytes_to_read);
*p_data += num_bytes_to_read;
*p_size -= num_bytes_to_read;
return TRUE;
diff --git a/gst/realmedia/rtspreal.c b/gst/realmedia/rtspreal.c
index 2fec0371..5804747e 100644
--- a/gst/realmedia/rtspreal.c
+++ b/gst/realmedia/rtspreal.c
@@ -436,7 +436,7 @@ rtsp_ext_real_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
if (strncmp (opaque_data, "MLTI", 4)) {
GST_DEBUG_OBJECT (ctx, "no MLTI found, appending all");
stream->type_specific_data_len = opaque_data_len;
- stream->type_specific_data = g_memdup (opaque_data, opaque_data_len);
+ stream->type_specific_data = g_memdup2 (opaque_data, opaque_data_len);
goto no_type_specific;
}
opaque_data += 4;
@@ -530,7 +530,7 @@ rtsp_ext_real_parse_sdp (GstRTSPExtension * ext, GstSDPMessage * sdp,
goto strange_opaque_data;
}
stream->type_specific_data =
- g_memdup (opaque_data, stream->type_specific_data_len);
+ g_memdup2 (opaque_data, stream->type_specific_data_len);
no_type_specific:
size =
diff --git a/meson.build b/meson.build
index f1846c61..4d8d1d4c 100644
--- a/meson.build
+++ b/meson.build
@@ -18,7 +18,7 @@ gst_version_is_dev = gst_version_minor % 2 == 1 and gst_version_micro < 90
have_cxx = add_languages('cpp', native: false, required: false)
-glib_req = '>= 2.44.0'
+glib_req = '>= 2.56.0'
gst_req = '>= @0@.@1@.0'.format(gst_version_major, gst_version_minor)
api_version = '1.0'
@@ -168,6 +168,10 @@ endif
gmodule_dep = dependency('gmodule-2.0', fallback : ['glib', 'libgmodule_dep'])
+if gmodule_dep.version().version_compare('< 2.67.4')
+ cdata.set('g_memdup2(ptr,sz)', '(G_LIKELY(((guint64)(sz)) < G_MAXUINT)) ? g_memdup(ptr,sz) : (g_abort(),NULL)')
+endif
+
ugly_args = ['-DHAVE_CONFIG_H']
configinc = include_directories('.')
libsinc = include_directories('gst-libs')