Thread: malloc reports corrupted top under stdout but not stderr

  1. #1
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733

    malloc reports corrupted top under stdout but not stderr

    I used this:
    Code:
    fprintf(stderr,"%s\n",path);
    fprintf(stdout,"%s\n",path);
    and only on the second line does it report an error, what sort of situations could cause this that you know of?
    Edit: Never mind, finally managed to dig out a related thread that was solved by adding more memory, tried looking around and realised the problem lay where I set the initial value for the number of characters to allocate
    Last edited by awsdert; 02-11-2020 at 12:42 PM.

  2. #2
    Registered User
    Join Date
    Apr 2011
    Location
    dust
    Posts
    70
    What error you are getting?
    Is the 'path' allocated memory by malloc?

  3. #3
    Registered User awsdert's Avatar
    Join Date
    Jan 2015
    Posts
    1,733
    Quote Originally Posted by ArunS View Post
    What error you are getting?
    Is the 'path' allocated memory by malloc?
    "malloc(): corrupted top size" is about all I can remember, as you'll note by my edit I fixed it after finding out it meant a lack of space and since the printf etc lacked awareness of string size I didn't know it had a buffer overflow occur

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. stdout,stdin,stderr querry
    By Amitesh93 in forum C Programming
    Replies: 8
    Last Post: 08-15-2013, 01:26 PM
  2. C programming in Mac. stderr and stdout redirection
    By sharonch in forum C Programming
    Replies: 0
    Last Post: 04-15-2013, 08:45 PM
  3. Redirecting stdout, stderr and stdin
    By iwabee in forum Linux Programming
    Replies: 9
    Last Post: 05-16-2005, 05:42 PM
  4. stderr vs stdout
    By JoshG in forum C Programming
    Replies: 6
    Last Post: 10-20-2002, 11:17 PM

Tags for this Thread