Skip to content

Commit

Permalink
fix: discard the rest of the line
Browse files Browse the repository at this point in the history
  • Loading branch information
isidroas committed Oct 29, 2024
1 parent 4ef6f60 commit a8b025b
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,19 @@ static char* ini_strncpy0(char* dest, const char* src, size_t size)
return dest;
}

#if !INI_ALLOW_REALLOC || INI_USE_STACK
/* Advance the stream. This is useful for the next line */
static void discard_remaining_line(void *stream, ini_reader reader){
char s[50];
size_t length;
do{
if (reader(s, sizeof(s), stream) == NULL)
break; // false positive
length=strlen(s);
} while(length == sizeof(s) - 1 && s[length-1] != '\n');
}
#endif

/* See documentation in header file. */
int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
void* user)
Expand Down Expand Up @@ -157,6 +170,7 @@ int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler,
#else
if (!error)
error=lineno;
discard_remaining_line(stream, reader);
break;
#endif
}
Expand Down

0 comments on commit a8b025b

Please sign in to comment.