Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7818027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:26:11+00:00 2026-06-02T06:26:11+00:00

I’ll ask you for some help with a really really simple program which implements

  • 0

I’ll ask you for some help with a really really simple program which implements a search planning algorithm. Well, the problem I got is a little weird for me: after allocating memory for a simple array of characters declared locally in a function, I work over this array, it has all the expected behaviors and everything goes ok, but when I call the free() function to this array before the function ends, the program stops and abort. If someone with some experience about this problem (or not…) could help me, i’d be really thankful. Well, here follows some lines of a “simulated” code to show what I’m talking about (it’s not exactly what’s written, but the :

char* v_AllTheWorld
char* v_ReadALineOfTheWorld;

v_AllTheWorld = malloc(COLUMNS * LINES * sizeof(char)); /*LINES and COLUMNS are defined constants*/

if(v_AllTheWorld == NULL)
{
    fprintf(stderr, "..."); //etc, etc.
    exit(1);
}

v_ReadALineOfTheWorld = malloc(COLUMNS * sizeof(char)); /*the "sizeof(char)" looks useless, but there's no point in talking about that here, i guess.*/

if(v_ReadALineOfTheWorld == NULL)
{
    fprintf(stderr, "..."); //etc, etc.
    exit(1);
}

while(/*some_condition (number of lines to be read)*/)
{
    //read data string from stream and stores in v_ReadALineOfTheWorld (fscanf);
    //appends the read data to v_AllTheWorld (strncat);
}

free(v_ReadALineOfTheWorld);
/*The program is stopping right after this call in the debug.*/

return v_AllTheWorld;

I didn’t put the head of the function, the declaration of it, and I didn’t represent the stream or how the data is manipulated in details, but no other calls of “malloc” or “free” are made and all the code that is written is executed unconditionally (out of any “if” or similar). Course, the last bahavior doesn’t include the allocation tests, but you got what I’m saying.

So, well, I hope I did it right asking this way, I hope I detailed the problem the right way and I hope you may help me.

Oh, I almost forgot that: as you probably noticed, the program is in C.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T06:26:14+00:00Added an answer on June 2, 2026 at 6:26 am

    This could happen if you are writing outside the bounds of v_ReadALineOfTheWorld. Some malloc libraries store info about the mallocd region in a wrapper around the region, and if you corrupt that info free could crash.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I am currently running into a problem where an element is coming back from
I am doing a simple coin flipping experiment for class that involves flipping a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.