1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-12 23:10:51 +00:00

[leds] Check return value of fscanf

This commit is contained in:
Witold Filipczyk 2022-10-16 16:08:33 +02:00
parent 4c775291c0
commit 9e7257c3b7

View File

@ -215,6 +215,7 @@ draw_temperature(struct session *ses, int xpos, int ypos, struct color_pair *col
struct terminal *term = ses->tab->term;
FILE *f;
int temp = 0;
int ret;
struct string text;
int i;
int length;
@ -222,9 +223,16 @@ draw_temperature(struct session *ses, int xpos, int ypos, struct color_pair *col
f = fopen(get_leds_temperature_filename(), "r");
if (!f) return 0;
fscanf(f, "%d", &temp);
if (!f) {
return 0;
}
ret = fscanf(f, "%d", &temp);
fclose(f);
if (ret < 1) {
return 0;
}
if (!init_string(&text)) {
return 0;
}