diff options
author | Colin Watson <cjwatson@debian.org> | 2022-01-02 03:12:28 +0000 |
---|---|---|
committer | Colin Watson <cjwatson@debian.org> | 2022-01-02 03:19:50 +0000 |
commit | a22f140354c80a7c5c52c4a413f1c929e105a24c (patch) | |
tree | 4d688f931cdb61c5ee3e60d861cbc9a50ea6550c /src/man.c | |
parent | 9f8d0ed464e884b10cd0ab2d1f5b341f0334519d (diff) |
Assert that some xasprintf calls return non-NULL
"gcc -fanalyzer" notices that xasprintf can return NULL in some
situations (string length > INT_MAX, invalid format string, or multibyte
conversion error), and that we weren't handling this in various cases
where we use the return value in contexts that require non-NULL values.
The situations seem obscure enough for simple asserts to be appropriate.
* lib/pathsearch.c (pathsearch): Assert that xasprintf returns non-NULL.
* lib/tempfile.c (create_tempdir): Likewise.
* lib/util.c (remove_directory): Likewise.
* libdb/db_lookup.c (make_multi_key): Likewise.
* libdb/db_store.c (make_content, dbstore): Likewise.
* src/check_mandirs.c (add_dir_entries, fix_permissions_tree): Likewise.
* src/compression.c (comp_file): Likewise.
* src/globbing.c (look_for_file): Likewise.
* src/man.c (main): Likewise.
* src/mandb.c (mandb, purge_catsubdirs): Likewise.
* src/manp.c (pathappend): Likewise.
* src/ult_src.c (find_include): Likewise.
* src/whatis.c (use_grep): Likewise.
* src/zsoelim.l (zsoelim_open_file): Likewise.
Diffstat (limited to 'src/man.c')
-rw-r--r-- | src/man.c | 2 |
1 files changed, 2 insertions, 0 deletions
@@ -4264,6 +4264,7 @@ int main (int argc, char *argv[]) if (subpages && first_arg < argc) { char *subname = xasprintf ( "%s-%s", nextarg, argv[first_arg]); + assert (subname); status = man (subname, &found); free (subname); if (status == OK) { @@ -4274,6 +4275,7 @@ int main (int argc, char *argv[]) if (!found_subpage && subpages && first_arg < argc) { char *subname = xasprintf ( "%s_%s", nextarg, argv[first_arg]); + assert (subname); status = man (subname, &found); free (subname); if (status == OK) { |