changeset 28355:418d7d213966

Move setting of O_NONBLOCK before lirc_readconfig, this avoids a memleak due to not freeing the lirc config on error.
author reimar
date Fri, 30 Jan 2009 15:41:45 +0000
parents 5b1f6e52673b
children db4b5631c26b
files input/lirc.c
diffstat 1 files changed, 7 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/input/lirc.c	Fri Jan 30 15:38:54 2009 +0000
+++ b/input/lirc.c	Fri Jan 30 15:41:45 2009 +0000
@@ -46,17 +46,17 @@
     return -1;
   }
 
-  if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
-    mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr,
-		    lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
+  mode = fcntl(lirc_sock, F_GETFL);
+  if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
+    mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n",
+	strerror(errno));
     lirc_deinit();
     return -1;
   }
 
-  mode = fcntl(lirc_sock, F_GETFL);
-  if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) {
-    mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n",
-	strerror(errno));
+  if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){
+    mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr,
+		    lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile);
     lirc_deinit();
     return -1;
   }