Fix memory overflow

Co-authored-by: MecryWork
This commit is contained in:
MecryWork 2021-08-12 20:28:37 +08:00 committed by GitHub
parent 60b885181a
commit 33bbd21e9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 2 deletions

View File

@ -88,6 +88,7 @@ static char *CacheSystem_calc_dir(const char *url)
fprintf(stderr, "CacheSystem_calc_dir(): mkdir(): %s\n", fprintf(stderr, "CacheSystem_calc_dir(): mkdir(): %s\n",
strerror(errno)); strerror(errno));
} }
free(fn);
free(cache_dir_root); free(cache_dir_root);
curl_free(escaped_url); curl_free(escaped_url);
curl_easy_cleanup(c); curl_easy_cleanup(c);
@ -115,10 +116,9 @@ void CacheSystem_init(const char *path, int url_supplied)
"CacheSystem_init(): opendir(): %s\n", strerror(errno)); "CacheSystem_init(): opendir(): %s\n", strerror(errno));
exit_failure(); exit_failure();
} }
closedir(dir);
META_DIR = path_append(path, "meta/"); META_DIR = path_append(path, "meta/");
DATA_DIR = path_append(path, "data/"); DATA_DIR = path_append(path, "data/");
/* Check if directories exist, if not, create them */ /* Check if directories exist, if not, create them */
if (mkdir(META_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) if (mkdir(META_DIR, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH)
&& (errno != EEXIST)) { && (errno != EEXIST)) {
@ -463,6 +463,8 @@ int CacheDir_create(const char *dirn)
if (i && (errno != EEXIST)) { if (i && (errno != EEXIST)) {
fprintf(stderr, "CacheDir_create(): mkdir(): %s\n", strerror(errno)); fprintf(stderr, "CacheDir_create(): mkdir(): %s\n", strerror(errno));
} }
free(datadirn);
free(metadirn);
return -i; return -i;
} }

View File

@ -71,6 +71,7 @@ LinkTable *LinkSystem_init(const char *raw_url)
ROOT_LINK_TBL = sonic_LinkTable_new_id3(0, "0"); ROOT_LINK_TBL = sonic_LinkTable_new_id3(0, "0");
} }
} }
free(url);
return ROOT_LINK_TBL; return ROOT_LINK_TBL;
} }

View File

@ -134,6 +134,7 @@ void parse_config_file(char ***argv, int *argc)
} }
} }
} }
free(full_path);
} }
static int static int