dir: Fix NULL dereference in replace_contents_compressed

g_file_replace can return NULL on failure (e.g. disk full). The
result was passed to g_converter_output_stream_new before the NULL
check. Move the check before use.
This commit is contained in:
Sebastian Wick committed 2026-07-27 13:41:00 +00:00
1 parent 2ff1d3b0b3
commit eb179c500c
1 file changed
+2 -1
+2 -1
View File
@@ -5741,10 +5741,11 @@ replace_contents_compressed (GFile *dest,
compressor = g_zlib_compressor_new (G_ZLIB_COMPRESSOR_FORMAT_GZIP, -1);
out = g_file_replace (dest, NULL, FALSE, G_FILE_CREATE_REPLACE_DESTINATION,
NULL, error);
out2 = g_converter_output_stream_new (G_OUTPUT_STREAM (out), G_CONVERTER (compressor));
if (out == NULL)
return FALSE;
out2 = g_converter_output_stream_new (G_OUTPUT_STREAM (out), G_CONVERTER (compressor));
if (!g_output_stream_write_all (out2,
g_bytes_get_data (contents, NULL),
g_bytes_get_size (contents),