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: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/8321>
This commit is contained in:
Guillaume Desmottes 2025-01-20 10:48:04 +01:00 committed by GStreamer Marge Bot
parent 60f4cd77d5
commit 5b4eb339a3

View file

@ -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;
}