If statement returns wrong result

void test(char *buffer, int size)
{
    int length = strlen(buffer);
    for (int i = 0; i <= length; ++i)
    {
        if (buffer[i] == '"')
        {
            int _size = i + size;
            if (_size > length)
                continue;

            if (buffer[i + size] == '"')
            {

            }
        }
    }
}

This is how I read the file.

FILE *file = NULL;
size_t filesize = 0;
uint8_t *filebuffer = 0;
            
file = fopen("tokens.txt", "r");
if (file)
{
fseek(file, 0, SEEK_END);
                filesize = ftell(file);
                fseek(file, 0, SEEK_SET);

                filebuffer = calloc(filesize + 1, 1);
                if (filebuffer)
                {
                    fread(filebuffer, 1, filesize, file);

                    for (size_t i = 0; i < filesize; i++)
                    {
                        if (filebuffer[i] == 0)
                            filebuffer[i] = '.';
                    }

                    char array[filesize];
                    strncpy(array, filebuffer, filesize);
                    array[filesize] = '\0';
                    test(array, 59);
                }
            }

"array" is char array[filesize];, "filesize" is ftell(file); (the file is valid and not NULL) the content of the file is asd"12345678912345678912345678912345678911111231231231231231232"asdasdasdasdasdasdss

enter image description here

for some weird reason it reaches to the "continue;" when the statement is not true...

Edit: I tried printing the values in the block of the if statement and for some reason I receive ->
Size: 122
Length: 84

Someone have any idea on how to solve it?


array[filesize] = '\0'; // access outside of array boundaries