File 2324-erl_call-Fix-code_checker-potential-leak-warning-for.patch of Package erlang

From 48759a7338c59c8cc1aa635e6bb9dcd513d92593 Mon Sep 17 00:00:00 2001
From: Kjell Winblad <kjellwinblad@gmail.com>
Date: Tue, 16 Mar 2021 15:25:11 +0100
Subject: [PATCH 4/6] erl_call: Fix code_checker potential leak warning for
 hostname_port_arg

---
 lib/erl_interface/src/prog/erl_call.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/lib/erl_interface/src/prog/erl_call.c b/lib/erl_interface/src/prog/erl_call.c
index 0b7848d2d9..08e17bb5c6 100644
--- a/lib/erl_interface/src/prog/erl_call.c
+++ b/lib/erl_interface/src/prog/erl_call.c
@@ -196,6 +196,8 @@ int main(int argc, char *argv[])
                 char* address_string_end = strchr(hostname_port_arg, ':');
                 if (address_string_end == NULL) {
                     flags.port = strtol(hostname_port_arg, NULL, 10);
+                    free(hostname_port_arg);
+                    hostname_port_arg = NULL;
                 } else {
                     flags.port = strtol(address_string_end + 1, NULL, 10);
                     /* Remove port part from hostname_port_arg*/
@@ -206,6 +208,9 @@ int main(int argc, char *argv[])
                 }
 
                 if (flags.port < 1 || flags.port > 65535) {
+                    if (hostname_port_arg != NULL) {
+                        free(hostname_port_arg);
+                    }
                     usage_error(progname, "-address");
                 }
                 i++;
@@ -1138,5 +1143,8 @@ void exit_free_flags_fields(int exit_status, struct call_flags* flags) {
     if (flags->apply != NULL) {
         free(flags->apply);
     }
+    if (flags->hostname != NULL) {
+        free(flags->hostname);
+    }
     exit(exit_status);
 }
-- 
2.26.2

openSUSE Build Service is sponsored by