1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-11-02 08:57:19 -04:00

[leds] Check return value of fscanf

This commit is contained in:
Witold Filipczyk 2022-06-24 22:03:07 +02:00
parent ad646029e3
commit 32afb683f2

View File

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