Defer heap variable initialisation after pledge
Otherwise `AGRS` and `program_arguments` remain allocated/unfreed in the early (extremely unlikely) pledge(2) failure case. Move their allocation before jq_init(), the first case of jumping to `out` where they are cleaned up, where it also seems to logically fit better than above between function entry, locale setup and OpenBSD specific pledge.
This commit is contained in:
1 parent
77dcaf3fdc
commit
7ab117a483
1 file changed
+3
-2
+3
-2
@@ -317,8 +317,6 @@ int main(int argc, char* argv[]) {
|
||||
int last_result = -1; /* -1 = no result, 0=null or false, 1=true */
|
||||
int badwrite;
|
||||
int options = 0;
|
||||
jv ARGS = jv_array(); /* positional arguments */
|
||||
jv program_arguments = jv_object(); /* named arguments */
|
||||
|
||||
#ifdef HAVE_SETLOCALE
|
||||
(void) setlocale(LC_ALL, "");
|
||||
@@ -339,6 +337,9 @@ int main(int argc, char* argv[]) {
|
||||
_setmode(fileno(stderr), _O_TEXT | _O_U8TEXT);
|
||||
#endif
|
||||
|
||||
jv ARGS = jv_array(); /* positional arguments */
|
||||
jv program_arguments = jv_object(); /* named arguments */
|
||||
|
||||
if (argc) progname = argv[0];
|
||||
|
||||
jq = jq_init();
|
||||
|
||||
Reference in new issue
Block a user