1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-26 15:53:26 +01:00

Add extra check to opened file opointer.

This commit is contained in:
AZ Huang 2013-11-28 03:31:10 +08:00
parent bb5ee93c88
commit f71f07b0ad

View File

@ -205,6 +205,11 @@ static void chat_onFileData(ToxWindow *self, Tox *m, int num, uint8_t filenum, u
uint8_t *filename = friends[num].file_receiver.filenames[filenum];
FILE *file_to_save = fopen(filename, "a");
// we have a problem here, but don't let it segfault
if (file_to_save == NULL) {
return;
}
if (fwrite(data, length, 1, file_to_save) != 1) {
wattron(ctx->history, COLOR_PAIR(RED));
wprintw(ctx->history, "* Error writing to file.\n");