> 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

Reply via email to