From 5b4eb339a3d854dedeb4d68c7f98ad4ce57bbce2 Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 20 Jan 2025 10:48:04 +0100 Subject: [PATCH] sparsefile: ensure error is set when read_buffer() returns 0 gst_sparse_file_read() is supposed to set @error when returning 0 but in some cases was not. Hopefully fix a crash in gst_download_buffer_read_buffer() which is checking error->code when 0 is returned. I'm not totally sure when this happens as I debugged this from a post mortem crash but returning a generic error here seems the safe thing to do. Part-of: --- subprojects/gstreamer/plugins/elements/gstsparsefile.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/subprojects/gstreamer/plugins/elements/gstsparsefile.c b/subprojects/gstreamer/plugins/elements/gstsparsefile.c index 81dd1ad25d..6e74753f13 100644 --- a/subprojects/gstreamer/plugins/elements/gstsparsefile.c +++ b/subprojects/gstreamer/plugins/elements/gstsparsefile.c @@ -383,7 +383,14 @@ error: gst_sparse_file_io_error_from_errno (errno), "Error reading file: %s", g_strerror (errno)); } else if (feof (file->file)) { + if (res == 0) { + g_set_error_literal (error, GST_SPARSE_FILE_IO_ERROR, + GST_SPARSE_FILE_IO_ERROR_FAILED, "Error reading file: EOF"); + } return res; + } else { + g_set_error_literal (error, GST_SPARSE_FILE_IO_ERROR, + GST_SPARSE_FILE_IO_ERROR_FAILED, "Error reading file"); } return 0; }