ipc: Set ipc message structure to 0 and double check before freeing
authorPaul Kocialkowski <contact@paulk.fr>
Sat, 23 Mar 2013 19:50:18 +0000 (20:50 +0100)
committerPaul Kocialkowski <contact@paulk.fr>
Sat, 23 Mar 2013 19:50:18 +0000 (20:50 +0100)
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
ipc.c

diff --git a/ipc.c b/ipc.c
index 4c4a244..6d3138a 100644 (file)
--- a/ipc.c
+++ b/ipc.c
@@ -83,6 +83,8 @@ int ipc_fmt_read_loop(struct ril_client *client)
        FD_SET(ipc_client_fd, &fds);
 
        while (1) {
+               memset(&info, 0, sizeof(info));
+
                if (ipc_client_fd < 0) {
                        LOGE("IPC FMT client fd is negative, aborting!");
                        return -1;
@@ -101,7 +103,7 @@ int ipc_fmt_read_loop(struct ril_client *client)
 
                        ipc_fmt_dispatch(&info);
 
-                       if (info.data != NULL)
+                       if (info.data != NULL && info.length > 0)
                                free(info.data);
                }
        }