On 16/12/11 08:41, Hannu Vuolasaho wrote:

> I wrote small test case which gave same Conditional jump or move depends on 
> uninitialised value errors.
>
> #include<stdio.h>
> #include<stdlib.h>
>
> int main(){
>    char * buffer;
>    size_t size;
>
>    if(getline(&buffer,&size, stdin)>0){
>      fputs(buffer, stdout);
>      free(buffer);
>    }
> }
>
> What I'm doing wrong? Should I use fread and fwrite?

You didn't initialise buffer to NULL before calling getline so it's 
behaviour is not deterministic. In particular when it checks whether the 
argument is NULL so as to decide whether to allocate a buffer it will be 
checking an uninitialised value.

Tom

-- 
Tom Hughes (t...@compton.nu)
http://compton.nu/

------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to