From cce54aff649a226b987a13638f8dfcc56179d64a Mon Sep 17 00:00:00 2001 From: James Maki Date: Fri, 7 May 2010 10:19:01 -0500 Subject: free lock_path --- src/atcmd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/atcmd.c b/src/atcmd.c index 6dee9ed..e153d39 100644 --- a/src/atcmd.c +++ b/src/atcmd.c @@ -1127,6 +1127,8 @@ int sms_device_close(int fd) if (lock_path) { unlink(lock_path); + free(lock_path); + lock_path = NULL; } return ret; @@ -1134,32 +1136,31 @@ int sms_device_close(int fd) int sms_device_open(void) { - int fd; + int fd = -1; int tmp; lock_path = device_lock(Global.core.device); if (!lock_path) { + sms_device_close(fd); return -1; } fd = tty_open(Global.core.device, Global.core.baud_rate); if (fd < 0) { - unlink(lock_path); + sms_device_close(fd); return -1; } tmp = tty_set_read_timeout(fd, Global.core.read_timeout); if (tmp < 0) { - close(fd); - unlink(lock_path); + sms_device_close(fd); return tmp; } if (Global.core.sms_init) { tmp = sms_atcmd_init(fd); if (tmp < 0) { - close(fd); - unlink(lock_path); + sms_device_close(fd); return tmp; } } -- cgit v1.2.3