diff --git a/ba/ba1100.cpp b/ba/ba1100.cpp index 53d1b467d..942a4ced0 100755 --- a/ba/ba1100.cpp +++ b/ba/ba1100.cpp @@ -347,14 +347,16 @@ void TManutenzione_app::open_history() { char line[16]; fgets(line,16,fp); - line[strlen(line) -1] = '\0'; - if (strlen(line)==0) _history_firm = -1; + int l = strlen(line); + + line[l > 0 ? l -1 : 0 ] = '\0'; + if (l==0) _history_firm = -1; else _history_firm = atol(line); } else { - fopen(History_file,"w"); + fp = fopen(History_file,"w"); _history_firm = -1; } fclose (fp);