On 03/28/2011 09:26 PM, Santosh Navale wrote:
> Hi,
> 
> The following is the message I get when I run valgrind on my C code.
> 
> ==16455== Use of uninitialised value of size 8
> ==16455==    at 0x4E6A76B: _itoa_word (_itoa.c:195)
> ==16455==    by 0x4E6B9B8: vfprintf (vfprintf.c:1613)
> ==16455==    by 0x4E75869: printf (printf.c:35)
> ==16455==    by 0x400830: main (matrix1.c:42)
> ==16455==  Uninitialised value was created by a heap allocation
> ==16455==    at 0x4C244E8: malloc (vg_replace_malloc.c:236)
> ==16455==    by 0x400752: main (matrix1.c:28)
> 
>>From my understanding something on line 28 in the file matrix1.c is causing
> an error. When I look at the source code,
> 
>   matrix = (int **) malloc (size * sizeof(int *));
>   for (row = 0; row < size; row++) {
>     matrix[row] = (int *) malloc (size * sizeof(int));
> <------------------- Line 28
>   }
> 
> I do not see how this can be a problem. Am I missing something very
> fundamental?
> 

You might. Line 28 allocates memory but it does not initialize it.
matrix[row[ is initialized, of course, but matrix[row][0] etc.. is not.

 Florian

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to