fixed some potential resource leaks
This commit is contained in:
parent
e2b474b130
commit
45247b4e35
1 changed files with 6 additions and 1 deletions
|
@ -61,9 +61,11 @@ long _alpm_gzopen_frontend(char *pathname, int oflags, int mode)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if((oflags & O_CREAT) && fchmod(fd, mode)) {
|
if((oflags & O_CREAT) && fchmod(fd, mode)) {
|
||||||
|
close(fd);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(!(gzf = gzdopen(fd, gzoflags))) {
|
if(!(gzf = gzdopen(fd, gzoflags))) {
|
||||||
|
close(fd);
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -114,6 +116,7 @@ int _alpm_copyfile(char *src, char *dest)
|
||||||
}
|
}
|
||||||
out = fopen(dest, "w");
|
out = fopen(dest, "w");
|
||||||
if(out == NULL) {
|
if(out == NULL) {
|
||||||
|
fclose(in);
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +165,7 @@ char *_alpm_strtrim(char *str)
|
||||||
return(str);
|
return(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
pch = (char*)(str + (strlen(str) - 1));
|
pch = (char *)(str + (strlen(str) - 1));
|
||||||
while(isspace(*pch)) {
|
while(isspace(*pch)) {
|
||||||
pch--;
|
pch--;
|
||||||
}
|
}
|
||||||
|
@ -218,6 +221,8 @@ int _alpm_lckmk(char *file)
|
||||||
*/
|
*/
|
||||||
int _alpm_lckrm(char *file)
|
int _alpm_lckrm(char *file)
|
||||||
{
|
{
|
||||||
|
/* ORE
|
||||||
|
we should close the file descriptor opened by lckmk */
|
||||||
return(unlink(file) == -1);
|
return(unlink(file) == -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue