From: Simon McVittie Date: Fri, 17 Mar 2023 12:53:42 +0000 (+0000) Subject: ostree_raw_file_to_content_stream: Make size default to 0 X-Git-Tag: archive/raspbian/2023.7-3+rpi1~1^2~9^2~2^2~16^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=722a4179f36439a01faf4afa33201ddd2f3ca46a;p=ostree.git ostree_raw_file_to_content_stream: Make size default to 0 Some existing code calls into ostree_raw_file_to_content_stream() with file objects that do not have the standard::size attribute. Since GLib 2.76.0, attempting to access the size of such an object raises a critical warning. Handle this more gracefully by defaulting the size to 0, like earlier versions of GLib did. Signed-off-by: Simon McVittie --- diff --git a/src/libostree/ostree-core.c b/src/libostree/ostree-core.c index 0d1b0d5d..f2f8c7a5 100644 --- a/src/libostree/ostree-core.c +++ b/src/libostree/ostree-core.c @@ -550,7 +550,9 @@ ostree_raw_file_to_content_stream (GInputStream *input, g_autoptr(GBytes) file_header = _ostree_file_header_new (file_info, xattrs); *out_input = header_and_input_to_stream (file_header, input); if (out_length) - *out_length = g_bytes_get_size (file_header) + g_file_info_get_size (file_info); + *out_length = g_bytes_get_size (file_header); + if (out_length && g_file_info_has_attribute (file_info, "standard::size")) + *out_length += g_file_info_get_size (file_info); return TRUE; }