Mercurial > mplayer.hg
comparison input/lirc.c @ 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 | 0f1b5b68af32 |
comparison
equal
deleted
inserted
replaced
28354:5b1f6e52673b | 28355:418d7d213966 |
---|---|
44 if((lirc_sock=lirc_init("mplayer",1))==-1){ | 44 if((lirc_sock=lirc_init("mplayer",1))==-1){ |
45 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed); | 45 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCopenfailed); |
46 return -1; | 46 return -1; |
47 } | 47 } |
48 | 48 |
49 if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){ | 49 mode = fcntl(lirc_sock, F_GETFL); |
50 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr, | 50 if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) { |
51 lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); | 51 mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n", |
52 strerror(errno)); | |
52 lirc_deinit(); | 53 lirc_deinit(); |
53 return -1; | 54 return -1; |
54 } | 55 } |
55 | 56 |
56 mode = fcntl(lirc_sock, F_GETFL); | 57 if(lirc_readconfig( lirc_configfile,&lirc_config,NULL )!=0 ){ |
57 if (mode < 0 || fcntl(lirc_sock, F_SETFL, mode | O_NONBLOCK) < 0) { | 58 mp_msg(MSGT_LIRC,MSGL_ERR,MSGTR_LIRCcfgerr, |
58 mp_msg(MSGT_LIRC, MSGL_ERR, "setting non-blocking mode failed: %s\n", | 59 lirc_configfile == NULL ? "~/.lircrc" : lirc_configfile); |
59 strerror(errno)); | |
60 lirc_deinit(); | 60 lirc_deinit(); |
61 return -1; | 61 return -1; |
62 } | 62 } |
63 | 63 |
64 return lirc_sock; | 64 return lirc_sock; |