<p>Corey Farrell has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/6663">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">vector: multiple evaluation of elem in AST_VECTOR_ADD_SORTED.<br><br>Use temporary variable to prevent multiple evaluations of elem argument.<br>This resolves a memory leak in res_pjproject startup.<br><br>ASTERISK-27317 #close<br><br>Change-Id: Ib960d7f5576f9e1a3c478ecb48995582a574e06d<br>---<br>M include/asterisk/vector.h<br>1 file changed, 3 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/63/6663/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/include/asterisk/vector.h b/include/asterisk/vector.h<br>index 2de84d2..400460b 100644<br>--- a/include/asterisk/vector.h<br>+++ b/include/asterisk/vector.h<br>@@ -315,16 +315,17 @@<br> #define AST_VECTOR_ADD_SORTED(vec, elem, cmp) ({ \<br> int res = 0; \<br> size_t __idx = (vec)->current; \<br>+ typeof(elem) __elem = (elem); \<br> do { \<br> if (__make_room((vec)->current, vec) != 0) { \<br> res = -1; \<br> break; \<br> } \<br>- while (__idx > 0 && (cmp((vec)->elems[__idx - 1], elem) > 0)) { \<br>+ while (__idx > 0 && (cmp((vec)->elems[__idx - 1], __elem) > 0)) { \<br> (vec)->elems[__idx] = (vec)->elems[__idx - 1]; \<br> __idx--; \<br> } \<br>- (vec)->elems[__idx] = elem; \<br>+ (vec)->elems[__idx] = __elem; \<br> (vec)->current++; \<br> } while (0); \<br> res; \<br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/6663">change 6663</a>. To unsubscribe, 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/6663"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 14 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib960d7f5576f9e1a3c478ecb48995582a574e06d </div>
<div style="display:none"> Gerrit-Change-Number: 6663 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>