Commit 48e633e8 authored by Yakubov, Sergey's avatar Yakubov, Sergey
Browse files

fix memory leaks

parent 1923a593
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ WriteMemoryCallback(void *contents, size_t size, size_t nmemb, void *userp) {

unsigned char* base64_urlsafe_decode(const char *input, int length, int *out_length) {
    // Convert base64 URL-safe to base64 standard
    char *converted = malloc(length + 2); // extra bytes for potential padding
    char *converted = malloc(length + 3); // extra bytes for potential padding
    strcpy(converted, input);
    for (int i = 0; i < length; ++i) {
        if (converted[i] == '-') converted[i] = '+';
+3 −2
Original line number Diff line number Diff line
@@ -17,12 +17,13 @@ int parse_config(const char* fname, json_config_t* config) {
    fseek (f, 0, SEEK_END);
    length = ftell (f);
    fseek (f, 0, SEEK_SET);
    buffer = malloc (length);
    buffer = malloc (length+1);
    if (!buffer) {
        return 1;
    }
    fread (buffer, 1, length, f);
    fclose (f);
    buffer[length]=0;
    
    cJSON *config_json = cJSON_Parse(buffer);
    if (config_json == NULL)