gfileinfo: Zero GTimeVal when failing g_file_info_get_modification_time()

Before commit ed8e86a7d4, this function would have silently returned a
zero-valued `GTimeVal` if the correct attributes weren’t present.

That partially regressed in commit ed8e86a7d4, which made it return with
a critical warning, but without zeroing the `GTimeVal`. The critical
warning can be ignored by users (it doesn’t abort the process unless
`G_DEBUG=fatal-criticals` is set), but the change in behaviour of
zeroing the `GTimeVal` could cause bugs.

See: #2907

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall 2023-03-21 12:11:38 +00:00
parent 2029d7e900
commit 2953c08261

View File

@ -1838,6 +1838,7 @@ g_file_info_get_modification_time (GFileInfo *info,
if (G_UNLIKELY (value == NULL)) if (G_UNLIKELY (value == NULL))
{ {
g_critical ("GFileInfo created without " G_FILE_ATTRIBUTE_TIME_MODIFIED); g_critical ("GFileInfo created without " G_FILE_ATTRIBUTE_TIME_MODIFIED);
result->tv_sec = result->tv_usec = 0;
g_return_if_reached (); g_return_if_reached ();
} }