PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] Valgrind error
Date: Thursday, 16 Apr 2020, 07:33:09


    > Message Posted By: Unknown
    >
    > I receive the following Valgrind error when trying to run ./Nine20 2 2 100
    > -123 123-
    >
    > ==3154== Command: ./Nine20 2 2 100 -123 123-
    > ==3154==
    > ==3154== Conditional jump or move depends on uninitialised value(s)
    > ==3154==    at 0x483BBE9: strlen (vg_replace_strmem.c:461)
    > ==3154==    by 0x4017A3: main (Nine20.c:143)
    >
    > For context, these are the relevant lines of code
    >
    > // remove the position P at the head of the queue
    >     char *p;
    >     remD(&d, &p);
    >     searchH(h, p, &reached_from, &n);
    >     int p_len = strlen(p);
    >
    > I'm calculating p_len so that I can iterate over the characters of p to
    > find out where '-' is.

The error message suggests that p is uninitialized, which
means that remD() did not give it a value.  But this is
not possible if the Deque d was created and remD() was
implemented correctly since remD() would set p = NULL in
that case.

Without being able to see and run your code, I cannot
diagnose the problem further.

--Stan-
PREV INDEX NEXT