LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   valgrind Query (https://www.linuxquestions.org/questions/linux-newbie-8/valgrind-query-947363/)

shruti123 05-29-2012 06:40 AM

valgrind Query
 
Hi,

valgrind shows the following log.

Invalid read of size 1

at 0x658AA7A: avmplus::String::equals(avmplus::String*) const (StringObject.cpp:186)
==2276== by 0x653037B: avmplus::AvmCore::findString(avmplus::String*) (AvmCore.cpp:3030)

My code is---

for (int32_t j = 0; j < len; j++)
{
if (str1[j] != str2[j]) ----------- crashing at this point
{
return false;
}
}

When i am checking the values at crash point in gdb its showing as

p len
$5 = 30
p j
$6 = 0
p str1[j]
$7 = 0 '\000'
p str2[j]
$8 = 72 'H'


Can anyone help me out to resolve the issue

Shruti.

pan64 05-31-2012 04:45 AM

your str (I do not know if str1 or str2) is not initialized properly. see: http://www.cprogramming.com/debugging/valgrind.html


All times are GMT -5. The time now is 10:07 PM.