<p>George Joseph has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/19268">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_crypto: Memory issues and and uninitialized variable error<br><br>ASTERISK-30235<br><br>Change-Id: Ia1e326e7b52cd06fd5e6c9009e3e63193c92f6cd<br>---<br>M main/test.c<br>M tests/test_crypto.c<br>2 files changed, 21 insertions(+), 5 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/68/19268/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/main/test.c b/main/test.c</span><br><span>index 747262c..03de33b 100644</span><br><span>--- a/main/test.c</span><br><span>+++ b/main/test.c</span><br><span>@@ -316,9 +316,13 @@</span><br><span> void ast_test_capture_free(struct ast_test_capture *capture)</span><br><span> {</span><br><span>       if (capture) {</span><br><span style="color: hsl(0, 100%, 40%);">-          free(capture->outbuf);</span><br><span style="color: hsl(120, 100%, 40%);">+             /*</span><br><span style="color: hsl(120, 100%, 40%);">+             * Need to use ast_std_free because this memory wasn't</span><br><span style="color: hsl(120, 100%, 40%);">+             * allocated by the astmm functions.</span><br><span style="color: hsl(120, 100%, 40%);">+           */</span><br><span style="color: hsl(120, 100%, 40%);">+           ast_std_free(capture->outbuf);</span><br><span>            capture->outbuf = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-              free(capture->errbuf);</span><br><span style="color: hsl(120, 100%, 40%);">+             ast_std_free(capture->errbuf);</span><br><span>            capture->errbuf = NULL;</span><br><span>   }</span><br><span>    capture->pid = -1;</span><br><span>@@ -330,6 +334,7 @@</span><br><span>  int fd0[2] = { -1, -1 }, fd1[2] = { -1, -1 }, fd2[2] = { -1, -1 };</span><br><span>   pid_t pid = -1;</span><br><span>      int status = 0;</span><br><span style="color: hsl(120, 100%, 40%);">+       FILE *cmd = NULL, *out = NULL, *err = NULL;</span><br><span> </span><br><span>      memset(capture, 0, sizeof(*capture));</span><br><span>        capture->pid = capture->exitcode = -1;</span><br><span>@@ -379,8 +384,6 @@</span><br><span>           exit(1);</span><br><span> </span><br><span>         } else {</span><br><span style="color: hsl(0, 100%, 40%);">-                FILE *cmd = NULL, *out = NULL, *err = NULL;</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span>          char buf[BUFSIZ];</span><br><span>            int wstatus, n, nfds;</span><br><span>                fd_set readfds, writefds;</span><br><span>diff --git a/tests/test_crypto.c b/tests/test_crypto.c</span><br><span>index 141781b..a3a0004 100644</span><br><span>--- a/tests/test_crypto.c</span><br><span>+++ b/tests/test_crypto.c</span><br><span>@@ -49,7 +49,7 @@</span><br><span> </span><br><span> static char *hexstring(const unsigned char *data, unsigned datalen)</span><br><span> {</span><br><span style="color: hsl(0, 100%, 40%);">-  char *buf = alloca(datalen * 2 + 1);</span><br><span style="color: hsl(120, 100%, 40%);">+  char *buf = ast_malloc(datalen * 2 + 1);</span><br><span>     unsigned n;</span><br><span> </span><br><span>      for (n = 0; n < datalen; ++n) {</span><br><span>@@ -532,6 +532,7 @@</span><br><span>     res = AST_TEST_PASS;</span><br><span> </span><br><span> cleanup:</span><br><span style="color: hsl(120, 100%, 40%);">+  ast_free(args[KEY]);</span><br><span>         ast_test_capture_free(&cap);</span><br><span>     return res;</span><br><span> }</span><br><span>@@ -610,6 +611,7 @@</span><br><span>       res = AST_TEST_PASS;</span><br><span> </span><br><span> cleanup:</span><br><span style="color: hsl(120, 100%, 40%);">+  ast_free(args[KEY]);</span><br><span>         ast_test_capture_free(&cap);</span><br><span>     return res;</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/19268">change 19268</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/+/19268"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: Ia1e326e7b52cd06fd5e6c9009e3e63193c92f6cd </div>
<div style="display:none"> Gerrit-Change-Number: 19268 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>