<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19344">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span></span><br></pre><div style="white-space:pre-wrap">Approvals:
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">test: initialize capture structure before freeing<br><br>ASTERISK-30232 #close<br><br>Change-Id: I2603e2cef8f93f6b0a6ef39f7eac744251bb3902<br>---<br>M include/asterisk/test.h<br>M main/test.c<br>M tests/test_crypto.c<br>3 files changed, 40 insertions(+), 2 deletions(-)<br><br></pre>
<pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/include/asterisk/test.h b/include/asterisk/test.h</span><br><span>index 12aed65..d2be92c 100644</span><br><span>--- a/include/asterisk/test.h</span><br><span>+++ b/include/asterisk/test.h</span><br><span>@@ -439,6 +439,16 @@</span><br><span> })</span><br><span> </span><br><span> /*!</span><br><span style="color: hsl(120, 100%, 40%);">+ * \brief Initialize the capture structure.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \since 16.30.0, 18.16.0, 19.8.0, 20.1.0</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * \param capture The structure describing the child process and its</span><br><span style="color: hsl(120, 100%, 40%);">+ * associated output.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+void ast_test_capture_init(struct ast_test_capture *capture);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+/*!</span><br><span>  * \brief Release the storage (buffers) associated with capturing</span><br><span>  * the output of an external child process.</span><br><span>  *</span><br><span>diff --git a/main/test.c b/main/test.c</span><br><span>index 03de33b..f06b557 100644</span><br><span>--- a/main/test.c</span><br><span>+++ b/main/test.c</span><br><span>@@ -313,6 +313,12 @@</span><br><span>  test->state = state;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+void ast_test_capture_init(struct ast_test_capture *capture)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     capture->outbuf = capture->errbuf = NULL;</span><br><span style="color: hsl(120, 100%, 40%);">+       capture->pid = capture->exitcode = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> void ast_test_capture_free(struct ast_test_capture *capture)</span><br><span> {</span><br><span>       if (capture) {</span><br><span>@@ -336,8 +342,7 @@</span><br><span>         int status = 0;</span><br><span>      FILE *cmd = NULL, *out = NULL, *err = NULL;</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- memset(capture, 0, sizeof(*capture));</span><br><span style="color: hsl(0, 100%, 40%);">-   capture->pid = capture->exitcode = -1;</span><br><span style="color: hsl(120, 100%, 40%);">+  ast_test_capture_init(capture);</span><br><span> </span><br><span>  if (data != NULL && datalen > 0) {</span><br><span>                if (pipe(fd0) == -1) {</span><br><span>diff --git a/tests/test_crypto.c b/tests/test_crypto.c</span><br><span>index a3a0004..1eec181 100644</span><br><span>--- a/tests/test_crypto.c</span><br><span>+++ b/tests/test_crypto.c</span><br><span>@@ -105,6 +105,8 @@</span><br><span> </span><br><span>    ast_test_status_update(test, "Executing RSA encryption test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span>@@ -190,6 +192,8 @@</span><br><span> </span><br><span>        ast_test_status_update(test, "Executing RSA decryption test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+        ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span>@@ -285,6 +289,8 @@</span><br><span> </span><br><span>        ast_test_status_update(test, "Executing RSA signing test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+   ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span>@@ -396,6 +402,8 @@</span><br><span> </span><br><span>        ast_test_status_update(test, "Executing RSA signature verification test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span>@@ -491,6 +499,8 @@</span><br><span> </span><br><span>        ast_test_status_update(test, "Executing AES-ECB encryption test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span>@@ -565,6 +575,8 @@</span><br><span> </span><br><span>        ast_test_status_update(test, "Executing AES-ECB decryption test\n");</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    ast_test_capture_init(&cap);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>   if (!ast_check_command_in_path(command)) {</span><br><span>           ast_test_status_update(test, "couldn't find %s\n", command);</span><br><span>           return res;</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19344">change 19344</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/19344"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 20 </div>
<div style="display:none"> Gerrit-Change-Id: I2603e2cef8f93f6b0a6ef39f7eac744251bb3902 </div>
<div style="display:none"> Gerrit-Change-Number: 19344 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Philip Prindeville <philipp@redfish-solutions.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>