From 45247b4e35cb219d5aaf5e4ed5b8be79fb410706 Mon Sep 17 00:00:00 2001 From: Aurelien Foret Date: Sun, 24 Apr 2005 09:14:25 +0000 Subject: fixed some potential resource leaks --- lib/libalpm/util.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/libalpm/util.c') diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index 48a912d9..d08af4e2 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -61,9 +61,11 @@ long _alpm_gzopen_frontend(char *pathname, int oflags, int mode) return -1; } if((oflags & O_CREAT) && fchmod(fd, mode)) { + close(fd); return -1; } if(!(gzf = gzdopen(fd, gzoflags))) { + close(fd); errno = ENOMEM; return -1; } @@ -114,6 +116,7 @@ int _alpm_copyfile(char *src, char *dest) } out = fopen(dest, "w"); if(out == NULL) { + fclose(in); return(1); } @@ -162,7 +165,7 @@ char *_alpm_strtrim(char *str) return(str); } - pch = (char*)(str + (strlen(str) - 1)); + pch = (char *)(str + (strlen(str) - 1)); while(isspace(*pch)) { pch--; } @@ -218,6 +221,8 @@ int _alpm_lckmk(char *file) */ int _alpm_lckrm(char *file) { + /* ORE + we should close the file descriptor opened by lckmk */ return(unlink(file) == -1); } -- cgit v1.2.3-54-g00ecf