Skip to content

Commit

Permalink
fix curl crash
Browse files Browse the repository at this point in the history
  • Loading branch information
sulincix committed May 27, 2024
1 parent 54ff1c3 commit 233f571
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/ccode/fetcher_curl.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ static size_t write_data_to_string(void *ptr, size_t size, size_t nmemb, void *s
return size*nmemb;
}

char fetcher_filename[PATH_MAX];


int fetcher_process_to_stderr(void *p, curl_off_t total, curl_off_t current, curl_off_t TotalToUpload, curl_off_t NowUploaded){
fprintf(stderr, "CUR: %ld TOT: %ld NAME: %s\r\n", current, total, fetcher_filename);
fprintf(stderr, "CUR: %ld TOT: %ld\r\n", current, total);
return 0;
}

Expand Down Expand Up @@ -95,6 +92,7 @@ void curl_options_common(CURL *curl, char* url){

int fetch(char* url, char* path){
FILE *fp;
char fetcher_filename[PATH_MAX];
strcpy(fetcher_filename,path);
CURL* curl=curl_easy_init();
finfo("Downloading: %s\n",path);
Expand All @@ -119,6 +117,7 @@ char* fetch_string(char* url){
CURL* curl=curl_easy_init();
struct string s;
init_string(&s);
char fetcher_filename[PATH_MAX];
strcpy(fetcher_filename,"");
curl_options_common(curl, url);
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data_to_string);
Expand Down
2 changes: 1 addition & 1 deletion src/ccode/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ int isdir(char *path){
}

#define c_mkdir(A, B) \
if (isexists(A)) \
if (!isexists(A)) \
if (mkdir(A, B) < 0) { \
ferror_add("%s %s\n", "failed to create directory.", A); \
}
Expand Down

0 comments on commit 233f571

Please sign in to comment.