url.h icon indicating copy to clipboard operation
url.h copied to clipboard

serious mem leak

Open takakawa opened this issue 7 years ago • 0 comments

I have read the code,and find that there are many memory leak in it. Such As some code in url_parse :


  char *search = malloc(sizeof(search));
  if (!search) return NULL;                               // you should not just return NULL,you should free previou malloced memroy
  tmp_path = strff(tmp_path, pathname_len);
  strcat(search, "");
  sscanf(tmp_path, "%[^#]", search);
  data->search = search;
  int search_len = strlen(search);
  free(tmp_path);

  char *query = malloc(sizeof(char));
  if (!query) return NULL;                            // you should not just return NULL,you should free previou malloced memroy
  sscanf(search, "?%s", query);
  data->query = query;

  char *hash = malloc(sizeof(char));
  if (!hash) return NULL;                     // you should not just return NULL,you should free previou malloced memroy

takakawa avatar May 29 '18 12:05 takakawa