aboutsummaryrefslogtreecommitdiff
path: root/src/find.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/find.c')
-rw-r--r--src/find.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/find.c b/src/find.c
index d2fc5a2..6db46e7 100644
--- a/src/find.c
+++ b/src/find.c
@@ -39,6 +39,7 @@ char *find_file(const char *root, const char *filename) {
}
if (!(rootpath = realpath(root, NULL))) {
+ free(path);
return NULL;
}
@@ -103,11 +104,13 @@ int find_in_file(const char *filename, const char *pattern) {
}
long int file_len = get_file_size(filename);
- if (file_len < 0) {
+ if (file_len == -1) {
+ fclose(fp);
return -1;
}
char *buffer = (char *)calloc((size_t) file_len, sizeof(char));
if (!buffer) {
+ fclose(fp);
return -1;
}
size_t pattern_len = strlen(pattern);