'Valgrind LeakDefinetlyLost

i have encountered a valgrind problem within this C function. I would be glad if i recive some help, ty.

char* readHTTPRequestFile() {
    FILE *HTTPRequestTXT = fopen("HTTP-Request.txt", "r+");

    int lengthOfTXT = 0;
    while (fgetc(HTTPRequestTXT) != '\n') {
        lengthOfTXT += 1;
    }
    fseek(HTTPRequestTXT, 0L, SEEK_SET);

    char* buffer = calloc(sizeof(char), lengthOfTXT);
    fgets(buffer, lengthOfTXT, HTTPRequestTXT);
    fclose(HTTPRequestTXT);
    return buffer;
}


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source