Skip to content
Snippets Groups Projects
  • Simon McVittie's avatar
    36694490
    utils: Always return non-NULL from _srt_recursive_list_content() · 36694490
    Simon McVittie authored
    
    Previously the result when the directory didn't exist was not guaranteed
    by the GPtrArray documentation: it could either be NULL (which would
    be OK) or a non-terminated array of 0 entries (which would lead to a
    segmentation fault in the caller). In practice it seems to have been
    reasonably reliably NULL, but let's make this predictable, by always
    returning a non-NULL (but possibly empty) GStrv.
    
    The practical result is that before,
    `_srt_recursive_list_content(..., "/nonexistent")` would return `NULL`,
    but now it returns `(const char[]) { NULL }`.
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
    36694490
    History
    utils: Always return non-NULL from _srt_recursive_list_content()
    Simon McVittie authored
    
    Previously the result when the directory didn't exist was not guaranteed
    by the GPtrArray documentation: it could either be NULL (which would
    be OK) or a non-terminated array of 0 entries (which would lead to a
    segmentation fault in the caller). In practice it seems to have been
    reasonably reliably NULL, but let's make this predictable, by always
    returning a non-NULL (but possibly empty) GStrv.
    
    The practical result is that before,
    `_srt_recursive_list_content(..., "/nonexistent")` would return `NULL`,
    but now it returns `(const char[]) { NULL }`.
    
    Signed-off-by: default avatarSimon McVittie <smcv@collabora.com>
system-info.c 141.45 KiB