<p>Vadim Yanitskiy has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/13450">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">libmsc/sms_queue.c: fix memleak in smsq_take_next_sms()<br><br>A memleak has been noticed after executing some of TTCN-3 test<br>cases. For example, the following ones:<br><br>  - MSC_Tests.TC_lu_and_mo_sms,<br>  - MSC_Tests.TC_lu_and_mt_sms.<br><br>The key point is that a test case basically disconnects too quick,<br>leaving some MT SMS messages (e.g. delivery reports) undelivered,<br>so they are getting stored in the SMSC's database.<br><br>As soon as the SMS queue is triggered, sms_submit_pending() would<br>retrieve pending messages from the database by calling function<br>smsq_take_next_sms() in loop.<br><br>This function in it's turn checks whether the subscriber is attached<br>or not. If not, the allocated 'gsm_sms' structure would not be<br>free()ed! Therefore, every time smsq_take_next_sms() is called,<br>a 'gsm_sms' structure for unattached subscriber is leaked.<br><br>Change-Id: Iad5e4d84d8d410ea43d5907e9ddf6e5fdb55bc7a<br>Closes: OS#3860<br>---<br>M src/libmsc/sms_queue.c<br>1 file changed, 6 insertions(+), 1 deletion(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/50/13450/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/libmsc/sms_queue.c b/src/libmsc/sms_queue.c</span><br><span>index c924dde..2987eba 100644</span><br><span>--- a/src/libmsc/sms_queue.c</span><br><span>+++ b/src/libmsc/sms_queue.c</span><br><span>@@ -226,8 +226,13 @@</span><br><span>              osmo_strlcpy(last_msisdn, sms->dst.addr, last_msisdn_buflen);</span><br><span> </span><br><span>                 /* Is the subscriber attached? If not, go to next SMS */</span><br><span style="color: hsl(0, 100%, 40%);">-                if (!sms->receiver || !sms->receiver->lu_complete)</span><br><span style="color: hsl(120, 100%, 40%);">+           if (!sms->receiver || !sms->receiver->lu_complete) {</span><br><span style="color: hsl(120, 100%, 40%);">+                 LOGP(DLSMS, LOGL_DEBUG,</span><br><span style="color: hsl(120, 100%, 40%);">+                            "Subscriber %s is not attached, skipping SMS %llu\n",</span><br><span style="color: hsl(120, 100%, 40%);">+                       vlr_subscr_msisdn_or_name(sms->receiver), sms->id);</span><br><span style="color: hsl(120, 100%, 40%);">+                        talloc_free(sms);</span><br><span>                    continue;</span><br><span style="color: hsl(120, 100%, 40%);">+             }</span><br><span> </span><br><span>                return sms;</span><br><span>  }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/13450">change 13450</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.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.osmocom.org/13450"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: osmo-msc </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Iad5e4d84d8d410ea43d5907e9ddf6e5fdb55bc7a </div>
<div style="display:none"> Gerrit-Change-Number: 13450 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Vadim Yanitskiy <axilirator@gmail.com> </div>