Fix: Fixup error paths in sim_op_check_cached
authorDenis Kenzior <denkenz@gmail.com>
Tue, 16 Mar 2010 20:44:29 +0000 (15:44 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Tue, 16 Mar 2010 20:45:04 +0000 (15:45 -0500)
src/sim.c

index 03d3e6e..cc258c8 100644 (file)
--- a/src/sim.c
+++ b/src/sim.c
@@ -1502,6 +1502,9 @@ static gboolean sim_op_check_cached(struct ofono_sim *sim)
 
        path = g_strdup_printf(SIM_CACHE_PATH, imsi, sim->phase, op->id);
 
+       if (path == NULL)
+               return FALSE;
+
        fd = TFR(open(path, O_RDONLY));
        g_free(path);
 
@@ -1537,7 +1540,10 @@ static gboolean sim_op_check_cached(struct ofono_sim *sim)
                goto cleanup;
        }
 
-       buffer = g_malloc(file_length);
+       buffer = g_try_malloc(file_length);
+
+       if (buffer == NULL)
+               goto cleanup;
 
        len = TFR(read(fd, buffer, file_length));