Valgrind报告分析:有条件的跳跃或移动取决于未初始化的值

时间:2018-10-13 08:56:06

标签: c memory-leaks valgrind

我正在尝试分析valgrind的报告。报告如下。为什么有条件跳转或移动取决于未初始化的值,所以在报告中多次显示。

=483== Conditional jump or move depends on uninitialised value(s)
==483==    at 0x4E7DA42: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)
==483== 
==483== Use of uninitialised value of size 8
==483==    at 0x4E7CEDB: _itoa_word (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E7DF55: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)
==483== 
==483== Conditional jump or move depends on uninitialised value(s)
==483==    at 0x4E7CEE5: _itoa_word (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E7DF55: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)
==483== 
==483== Conditional jump or move depends on uninitialised value(s)
==483==    at 0x4E7DFA4: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)
==483== 
==483== Conditional jump or move depends on uninitialised value(s)
==483==    at 0x4E7DB0D: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)
==483== 
==483== Conditional jump or move depends on uninitialised value(s)
==483==    at 0x4E7DB90: vfprintf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4E878C8: printf (in /usr/lib64/libc-2.17.so)
==483==    by 0x4005B2: main (p2.c:11)
==483==  Uninitialised value was created by a stack allocation
==483==    at 0x40057D: main (p2.c:7)

下面是示例代码。

main()
{
    int *a,b;
    a=(int *)malloc(sizeof(int));
    *a=b;
    printf("%d",*a);
}

0 个答案:

没有答案