lib/core: Avoid NULL deref in content_file_parse() if out variable unset

Prep for a change in `ostree_repo_load_file()`.  We would crash if a
caller had `out_file_info = NULL`, because we deref `ret_file_info`
below it.

Closes: #951
Approved by: jlebon
This commit is contained in:
Colin Walters 2017-06-22 13:01:50 -04:00 committed by Atomic Bot
parent 90b587e2c8
commit aafda9073a
1 changed files with 3 additions and 4 deletions

View File

@ -644,7 +644,7 @@ ostree_content_stream_parse (gboolean compressed,
if (compressed) if (compressed)
{ {
if (!zlib_file_header_parse (file_header, if (!zlib_file_header_parse (file_header,
out_file_info ? &ret_file_info : NULL, &ret_file_info,
out_xattrs ? &ret_xattrs : NULL, out_xattrs ? &ret_xattrs : NULL,
error)) error))
return FALSE; return FALSE;
@ -652,12 +652,11 @@ ostree_content_stream_parse (gboolean compressed,
else else
{ {
if (!file_header_parse (file_header, if (!file_header_parse (file_header,
out_file_info ? &ret_file_info : NULL, &ret_file_info,
out_xattrs ? &ret_xattrs : NULL, out_xattrs ? &ret_xattrs : NULL,
error)) error))
return FALSE; return FALSE;
if (ret_file_info) g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8);
g_file_info_set_size (ret_file_info, input_length - archive_header_size - 8);
} }
g_autoptr(GInputStream) ret_input = NULL; g_autoptr(GInputStream) ret_input = NULL;