diff options
author | Arnold D. Robbins <arnold@skeeve.com> | 2022-02-22 20:12:28 +0200 |
---|---|---|
committer | Arnold D. Robbins <arnold@skeeve.com> | 2022-02-22 20:12:28 +0200 |
commit | 80de2f7c9bc519fb820033a530e1657977117a33 (patch) | |
tree | e0b8b01efe8040cdb7b5039d17aa93a85bc0b442 | |
parent | 938afb4d7acb9974d5789dfe4e322c0ccce0541e (diff) | |
download | egawk-80de2f7c9bc519fb820033a530e1657977117a33.tar.gz egawk-80de2f7c9bc519fb820033a530e1657977117a33.tar.bz2 egawk-80de2f7c9bc519fb820033a530e1657977117a33.zip |
Fix resource links found by Coverity.
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | ext.c | 1 | ||||
-rw-r--r-- | extension/ChangeLog | 7 | ||||
-rw-r--r-- | extension/readfile.c | 4 | ||||
-rw-r--r-- | io.c | 4 | ||||
-rw-r--r-- | symbol.c | 1 |
6 files changed, 23 insertions, 3 deletions
@@ -1,3 +1,12 @@ +2022-02-22 Arnold D. Robbins <arnold@skeeve.com> + + Fix resource links found by Coverity. Thanks to + Jakub Martisko <jamartis@redhat.com> for the report. + + * ext.c (make_builtin): Free install_name before returning. + * io.c (remap_std_file): Unconditionally close newfd. + * symbol.c (load_symbols): Unref built_in also. + 2022-12-10 Andrew J. Schorr <aschorr@telemetry-investments.com> * io.c (wait_any): When saving a saved exit status returned by @@ -128,6 +128,7 @@ make_builtin(const char *name_space, const awk_ext_func_t *funcinfo) /* multiple extension() calls etc. */ if (do_lint) lintwarn(_("make_builtin: function `%s' already defined"), name); + free(install_name); return awk_false; } else /* variable name etc. */ diff --git a/extension/ChangeLog b/extension/ChangeLog index fc90156f..69896748 100644 --- a/extension/ChangeLog +++ b/extension/ChangeLog @@ -1,3 +1,10 @@ +2022-02-22 Arnold D. Robbins <arnold@skeeve.com> + + Fix resource links found by Coverity. Thanks to + Jakub Martisko <jamartis@redhat.com> for the report. + + * readfile.c (do_readfile): Close fd if text == NULL. + 2021-12-10 Arnold D. Robbins <arnold@skeeve.com> * rwarray.c (write_number, read_number): Reformat comments a bit. diff --git a/extension/readfile.c b/extension/readfile.c index 6c3307cd..def414ee 100644 --- a/extension/readfile.c +++ b/extension/readfile.c @@ -121,8 +121,10 @@ do_readfile(int nargs, awk_value_t *result, struct awk_ext_func *unused) } text = read_file_to_buffer(fd, & sbuf); - if (text == NULL) + if (text == NULL) { + close(fd); goto done; /* ERRNO already updated */ + } close(fd); make_malloced_string(text, sbuf.st_size, result); @@ -628,8 +628,8 @@ remap_std_file(int oldfd) if (newfd >= 0) { /* if oldfd is open, dup2() will close oldfd for us first. */ ret = dup2(newfd, oldfd); - if (ret == 0) - close(newfd); + // close unconditionally, calling code assumes it + close(newfd); } else ret = 0; @@ -644,6 +644,7 @@ load_symbols() unref(scalar); unref(untyped); unref(array); + unref(built_in); } /* check_param_names --- make sure no parameter is the name of a function */ |