From d7119c21fa566d2d5834cc5aa8627655ee849160 Mon Sep 17 00:00:00 2001 From: Clecio Jung Date: Sat, 15 Apr 2023 11:07:01 -0300 Subject: Update the README example --- ini_file.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'ini_file.c') diff --git a/ini_file.c b/ini_file.c index a18473e..e07b9b1 100644 --- a/ini_file.c +++ b/ini_file.c @@ -211,6 +211,10 @@ static char *copy_sized_string(struct Ini_File *ini_file, const char *const size if (ini_file == NULL) { return NULL; } + /* Checks if the string fits into the maximum buffer size */ + if ((len + 1) >= STRING_ALLOCATOR_BUFFER_SIZE) { + return NULL; + } if ((ini_file->strings == NULL) || ((ini_file->string_index + len + 1) > sizeof(ini_file->strings->buffer))) { /* Insert new buffer at the beginning */ struct String_Buffer *new_strings = malloc(sizeof(struct String_Buffer)); -- cgit v1.2.3