Don't emit SubscriberNumbers multiple times
authorDenis Kenzior <denkenz@gmail.com>
Tue, 4 Aug 2009 18:59:30 +0000 (13:59 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 4 Aug 2009 20:10:49 +0000 (15:10 -0500)
We would emit the signal even if the record could not be parsed

src/sim.c

index 30c9473..8ef1c26 100644 (file)
--- a/src/sim.c
+++ b/src/sim.c
@@ -191,7 +191,7 @@ static void sim_msisdn_read_cb(struct ofono_modem *modem, int ok,
 {
        struct sim_manager_data *sim = modem->sim_manager;
        int total;
-       struct ofono_phone_number *ph;
+       struct ofono_phone_number ph;
 
        if (!ok)
                goto check;
@@ -204,15 +204,14 @@ static void sim_msisdn_read_cb(struct ofono_modem *modem, int ok,
 
        total = length / record_length;
 
-       ph = g_new(struct ofono_phone_number, 1);
+       if (sim_adn_parse(data, record_length, &ph) == TRUE) {
+               struct ofono_phone_number *own;
 
-       if (sim_adn_parse(data, record_length, ph) == FALSE) {
-               g_free(ph);
-               goto check;
+               own = g_new(struct ofono_phone_number, 1);
+               memcpy(own, &ph, sizeof(struct ofono_phone_number));
+               sim->own_numbers = g_slist_prepend(sim->own_numbers, own);
        }
 
-       sim->own_numbers = g_slist_prepend(sim->own_numbers, ph);
-
        if (record != total)
                return;