Skip to content
Snippets Groups Projects
Commit 54e20602 authored by Krasimir Balchev's avatar Krasimir Balchev
Browse files

Fixed bugs in get_history_size and load_history functions.

parent 949810ca
No related branches found
No related tags found
No related merge requests found
......@@ -174,7 +174,7 @@ int get_cmnd_from_history(long commandNum) {
int get_history_size() {
int historySize = 0;
while (history[historySize].line != NULL) {
while (history[historySize].line != NULL && historySize < MAX_HISTORY_LENGTH) {
historySize++;
}
......@@ -315,7 +315,7 @@ void load_history() {
if (fp != NULL) {
String line = malloc(sizeof(char) * MAX_INPUT_LENGTH);
int index = 0;
while (fgets(line, MAX_INPUT_LENGTH, fp) != NULL && index <= MAX_HISTORY_LENGTH) {
while (fgets(line, MAX_INPUT_LENGTH, fp) != NULL && index < MAX_HISTORY_LENGTH) {
// Remove trailing newlie character
char *pos = strchr(line, '\n');
if (pos != NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment