mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
[leds] Check return value of fscanf
This commit is contained in:
parent
ad646029e3
commit
32afb683f2
@ -217,6 +217,7 @@ draw_temperature_node(struct session *ses, int xpos, int ypos, unsigned int node
|
||||
struct terminal *term = ses->tab->term;
|
||||
FILE *f;
|
||||
int temp = 0;
|
||||
int ret;
|
||||
struct string text;
|
||||
int i;
|
||||
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");
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user