aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog9
-rw-r--r--ext.c1
-rw-r--r--extension/ChangeLog7
-rw-r--r--extension/readfile.c4
-rw-r--r--io.c4
-rw-r--r--symbol.c1
6 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index ce603e94..f20dd21f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/ext.c b/ext.c
index 5815c739..e5b6a2a0 100644
--- a/ext.c
+++ b/ext.c
@@ -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);
diff --git a/io.c b/io.c
index 07d83689..cf54cdd4 100644
--- a/io.c
+++ b/io.c
@@ -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;
diff --git a/symbol.c b/symbol.c
index 300fa871..b89c01e0 100644
--- a/symbol.c
+++ b/symbol.c
@@ -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 */