diff --git a/libretro-common/file/archive_file.c b/libretro-common/file/archive_file.c index 659140f1f3..4548456e42 100644 --- a/libretro-common/file/archive_file.c +++ b/libretro-common/file/archive_file.c @@ -84,25 +84,29 @@ static void file_archive_free(file_archive_file_data_t *data) static file_archive_file_data_t* file_archive_open(const char *path) { - file_archive_file_data_t *data = (file_archive_file_data_t*)calloc(1, sizeof(*data)); + file_archive_file_data_t *data = (file_archive_file_data_t*) + malloc(sizeof(*data)); if (!data) return NULL; - data->fd = open(path, O_RDONLY); + data->fd = open(path, O_RDONLY); + data->data = NULL; + data->size = 0; /* Failed to open archive. */ if (data->fd < 0) goto error; - data->size = path_get_size(path); + data->size = path_get_size(path); if (!data->size) return data; - data->data = mmap(NULL, data->size, PROT_READ, MAP_SHARED, data->fd, 0); + data->data = mmap(NULL, + data->size, PROT_READ, MAP_SHARED, data->fd, 0); if (data->data == MAP_FAILED) { - data->data = NULL; + data->data = NULL; /* Failed to mmap() file */ goto error; @@ -128,21 +132,24 @@ static void file_archive_free(file_archive_file_data_t *data) static file_archive_file_data_t* file_archive_open(const char *path) { - int64_t ret = -1; - bool read_from_file = false; + int64_t ret = -1; + bool read_from_file = false; file_archive_file_data_t *data = (file_archive_file_data_t*) - calloc(1, sizeof(*data)); + malloc(sizeof(*data)); if (!data) return NULL; - read_from_file = filestream_read_file(path, &data->data, &ret); + data->data = NULL; + data->size = 0; + read_from_file = filestream_read_file( + path, &data->data, &ret); /* Failed to open archive? */ if (!read_from_file || ret < 0) goto error; - data->size = ret; + data->size = ret; return data; error: diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index e82a361b93..4f265876fa 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -89,6 +89,7 @@ struct http_connection_t struct http_socket_state_t sock_state; }; +/* TODO/FIXME - static globals */ static char urlencode_lut[256]; static bool urlencode_lut_inited = false; @@ -116,9 +117,8 @@ void net_http_urlencode(char **dest, const char *source) if (!urlencode_lut_inited) urlencode_lut_init(); - enc = (char*)calloc(1, len); - - *dest = enc; + enc = (char*)calloc(1, len); + *dest = enc; for (; *source; source++) { @@ -252,7 +252,7 @@ static void net_http_send_str( struct http_connection_t *net_http_connection_new(const char *url, const char *method, const char *data) { - struct http_connection_t *conn = (struct http_connection_t*)calloc(1, + struct http_connection_t *conn = (struct http_connection_t*)malloc( sizeof(*conn)); if (!conn) @@ -264,6 +264,19 @@ struct http_connection_t *net_http_connection_new(const char *url, return NULL; } + conn->domain = NULL; + conn->location = NULL; + conn->urlcopy = NULL; + conn->scan = NULL; + conn->methodcopy = NULL; + conn->contenttypecopy = NULL; + conn->postdatacopy = NULL; + conn->useragentcopy = NULL; + conn->port = 0; + conn->sock_state.fd = 0; + conn->sock_state.ssl = false; + conn->sock_state.ssl_ctx= NULL; + if (method) conn->methodcopy = strdup(method);