cpulimit (1.1-13) 04_opendir_leak.patch

Summary

 cpulimit.c |    8 ++++++++
 1 file changed, 8 insertions(+)

    
download this patch

Patch contents

Author: Johan Walles <johan.walles@gmail.com>
Bug-Debian: http://bugs.debian.org/564517
Description: Each time cpulimit finds a process to limit, it does a goto
 past the call to closedir(). Plug that leak.
Forwarded: yes
Origin: vendor, cf. bug
Reviewed-By: gregor herrmann <gregoa@debian.org>
Last-Update: 2010-01-11

--- a/cpulimit.c
+++ b/cpulimit.c
@@ -98,6 +98,10 @@
 				//pid detected
 				if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
 					//process is ok!
+					if (closedir(dip) == -1) {
+						perror("closedir");
+						return -1;
+					}
 					goto done;
 				}
 				else {
@@ -188,6 +192,10 @@
 					if (found==1) {
 						if (kill(pid,SIGSTOP)==0 &&  kill(pid,SIGCONT)==0) {
 							//process is ok!
+							if (closedir(dip) == -1) {
+								perror("closedir");
+								return -1;
+							}
 							goto done;
 						}
 						else {