MertGunduz / yiffy

furry tui app for searching/downloading/fetching images from e621/e926
https://mertgunduz.github.io/yiffy/
GNU General Public License v3.0
7 stars 1 forks source link

Fix the /src/msg/file_open_error_msg.c bug. #24

Closed MertGunduz closed 5 months ago

MertGunduz commented 5 months ago

/src/msg/file_open_error_msg.c needs bugfix.

If the file pointer is NULL, you shouldn't do fclose on it. It will cause undefined behavior.

It might crash or harm current loaded memory on old systems.

/**
 * @file file_open_error_msg.c
 * 
 * @brief This file is used to show some information about file permissions when yiffy is not able to read file.  
 * 
 * @author Mehmet Mert Gunduz (merttgg@gmail.com)
 * 
 * @date 05/08/2023
*/

#include "yiffy_messages.h"

/**
 * @brief Shows some information about file permissions when yiffy is not able to read file.  
 * 
 * @param file This is used to close the file. 
*/
void file_open_error_msg(FILE *file)
{ 
    fprintf(stderr, "yiffy: error opening the file.\n");
    fprintf(stderr, "yiffy: please check the file read-write permissions.\n");

    fclose(file);
}

The FILE *file parameter and fclose function should be removed from the code.

After removing the code files using this function should be fixed.

MertGunduz commented 5 months ago

Issue fixed/