CS50, PSET5-Speller. Помощь по ошибке при запуске valgrind - PullRequest
1 голос
/ 09 мая 2020

Я получаю следующую ошибку.

==14574== Invalid read of size 1.
==14574==    at 0x4C33614: strcasecmp (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==14574==    by 0x40108C: check (dictionary.c:38)
==14574==    by 0x400C89: main (speller.c:113)

Looks like you're trying to access 1 byte of memory that isn't yours? Did you try to index into an array beyond its bounds? Take a closer look at line 38 of dictionary.c.

Ниже приведен мой блок кода, содержащий строку 38.

bool check(const char *word)
{
    node *cursor = hash_table[hash(word)];

    while (cursor != NULL)
    {
        if (strcasecmp(cursor -> word, word) == 0)  //This is line 38// 
        {
            return true;
        }
        cursor = cursor->next;
    }
    return false;
}
...