I did not managed to reproduce memleak by manually triggering
db_sync_subscriber with "subscriber id 2 authorized 1" multiple times.
When does it happen?
Also, what to you suggest to improve readability?

I'll send revised version shortly.

On 05/03/2016 11:05 AM, Holger Freyther wrote:
>> On 03 May 2016, at 10:43, [email protected] wrote:
>>
>> +    if (subscriber->extension[0] != '\0')
>> +            dbi_conn_quote_string_copy(conn,
>> +                                       subscriber->extension, &q_extension);
>> +    else
>> +            q_extension = strdup("NULL");
>>      
>>      if (subscriber->tmsi != GSM_RESERVED_TMSI) {
>>              sprintf(tmsi, "%u", subscriber->tmsi);
>> @@ -1043,15 +1049,17 @@ int db_subscriber_delete(struct gsm_subscriber 
>> *subscr)
>>      }
>>      dbi_result_free(result);
>>
>> -    result = dbi_conn_queryf(conn,
>> -                    "DELETE FROM SMS WHERE src_addr=%s OR dest_addr=%s",
>> -                    subscr->extension, subscr->extension);
>> -    if (!result) {
>> -            LOGP(DDB, LOGL_ERROR,
>> -                    "Failed to delete SMS for %llu\n", subscr->id);
>> -            return -1;
>> +    if (subscr->extension[0] != '\0') {
>> +            result = dbi_conn_queryf(conn,
>> +                        "DELETE FROM SMS WHERE src_addr=%s OR dest_addr=%s",
>> +                                     subscr->extension, subscr->extension);
>> +            if (!result) {
>> +                    LOGP(DDB, LOGL_ERROR,
>> +                         "Failed to delete SMS for %llu\n", subscr->id);
>> +                    return -1;
>> +            }
>> +            dbi_result_free(result);
>>      }
>> -    dbi_result_free(result);
> Starts to be less readable, q_extension will leak in the error path as well 
> (and probably leaked before as well).
>
> holger

-- 
Max Suraev <[email protected]> http://www.sysmocom.de/
======================================================================= 
* sysmocom - systems for mobile communications GmbH
* Alt-Moabit 93 
* 10559 Berlin, Germany
* Sitz / Registered office: Berlin, HRB 134158 B 
* Geschaeftsfuehrer / Managing Directors: Holger Freyther, Harald Welte 

Reply via email to