diff options
-rw-r--r-- | src/net.c | 7 | ||||
-rw-r--r-- | src/wine.c | 31 |
2 files changed, 25 insertions, 13 deletions
@@ -18,7 +18,7 @@ static size_t memoryCallback(void* contents, size_t size, size_t nmemb, void* us uint8_t* ptr = realloc(mem->memory, mem->size + realsize + 1); if(ptr == NULL) { - puts("out of memory"); + fprintf(stderr, "Unable to allocate memory\n"); return 0; } @@ -55,6 +55,7 @@ struct MemoryStruct* downloadToRam(const char* URL, long noprogress) if (chunk) { + // if we managed to allocate the chunk lets assume we can allocate at least 1 byte chunk->memory = malloc(1); chunk->size = 0; @@ -90,6 +91,10 @@ struct MemoryStruct* downloadToRam(const char* URL, long noprogress) curl_easy_cleanup(curl_handle); curl_global_cleanup(); } + else + { + fprintf(stderr, "Unable to allocate memory\n"); + } return chunk; } @@ -385,22 +385,29 @@ enum wine_type_t check_wine_ver(char* winepath, size_t size) char* winepathcopy = NULL; winepathcopy = malloc(size); - strncpy(winepathcopy, winepath, size); - strncat(winepathcopy, WINEBIN, size - strlen(winepathcopy)); - - if (isFile(winepathcopy)) + if (winepathcopy) { - free(winepathcopy); - return WINE_NORMAL; - } + strncpy(winepathcopy, winepath, size); + strncat(winepathcopy, WINEBIN, size - strlen(winepathcopy)); + + if (isFile(winepathcopy)) + { + free(winepathcopy); + return WINE_NORMAL; + } - strncpy(winepathcopy, winepath, size); - strncat(winepathcopy, PROTONBIN, size - strlen(winepathcopy)); + strncpy(winepathcopy, winepath, size); + strncat(winepathcopy, PROTONBIN, size - strlen(winepathcopy)); - if (isFile(winepathcopy)) + if (isFile(winepathcopy)) + { + free(winepathcopy); + return WINE_PROTON; + } + } + else { - free(winepathcopy); - return WINE_PROTON; + fprintf(stderr, "Unable to allocate memory\n"); } return WINE_NONE; |