This error occurs because some other part of your code has corrupted the heap. We can’t tell you what that error is without seeing the rest of the code.
The fact that FINE 7
is not printed tells you that realloc
is failing. And that failure must be because buffer
is invalid due to a heap corruption earlier in the execution.
Orthogonal to your actual problem, sizeof(char)
is 1
by definition so it makes sense to remove it from the code.
Related Posts:
- How to properly malloc for array of struct in C
- Data argument not used by format strings in C
- difference between
and - Use of cudamalloc(). Why the double pointer?
- Allocating string with malloc
- Incorrect checksum for freed object on malloc
- Simple way to check if a string contains another string in C?
- Difference between sizeof(char) and sizeof(char *)
- Proper way to empty a C-String
- How do you allow spaces to be entered using scanf?
- Tokenizing strings in C
- How to allocate array of pointers for strings by malloc in C?
- Realloc Invalid Pointer in C
- How to format strings using printf() to get equal length in the output
- How to format strings using printf() to get equal length in the output
- Split string with multiple delimiters using strtok in C
- Pointer to a string in C?
- Convert long long to string in C?
- How do I check if a string contains a certain character?
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- Convert Char to String in C
- How to convert a string to integer in C?
- How do I create an array of strings in C?
- What is the difference between char s[] and char *s?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- What is use of c_str function In c++
- How do I properly compare strings in C?
- Returning string from C function
- C – The %x format specifier
- Incompatible implicit declaration of built-in function ‘malloc’
- Need more information about Aborted (core dumped)
- What is the cause of flexible array member not at end of struct error?
- Reversing a string in C
- How to remove the character at a given index from a string in C?
- waitpid, wnohang, wuntraced. How do I use these
- Split string with delimiters in C
- Warning: assignment from incompatible pointer type
- How do malloc() and free() work?
- C: error: expected ‘)’ before ‘;’ token
- execv vs execvp, why just one of them require the exact file’s path?
- Warning/error “function declaration isn’t a prototype”
- Returning an array using C
- warning: initializer element is not computable at load time
- How to prevent multiple definitions in C?
- How can you print multiple variables inside a string using printf?
- Flushing buffers in C
- What are 0x01 and 0x80 representative of in C bitwise operations?
- How to make parent wait for all child processes to finish?
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- Reading string by char till end of line C/C++
- OpenGL — GL_LINE_LOOP —
- How to use EOF to run through a text file in C?
- Valgrind complains with “Invalid write of size 8”
- Removing trailing newline character from fgets() input
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Segmentation fault (core dumped) due to fgets – I think
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- error: too few arguments to function `printDay’ (C language)
- Is there a good Valgrind substitute for Windows?
- Difference between “move” and “li” in MIPS assembly language
- How to empty a char array?
- Undefined reference to main – collect2: ld returned 1 exit status
- How can one see content of stack with GDB?
- Is there a way to have printf() properly print out an array (of floats, say)?
- malloc(): memory corruption
- Where is the
header file on Linux? Why can’t I find ? - What is the difference between %g and %f in C?
- Why is the sizeof(int) == sizeof(long)?
- Structure padding and packing
- Passing string to a function in C – with or without pointers?
- Allocating char array using malloc
- Trim a string in C [duplicate]
- Casting a pointer to an int
- Reading in double values with scanf in c
- Difference between char* and char** (in C)
- The difference between char * and char[] [duplicate]
- “-bash: gcc: command not found” using cygwin when compiling c?
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)
- What are the differences between if, else, and else if?
- Should I use printf(“\n”) or putchar(‘\n’) to print a newline in C?
- error: struct has no member named X
- strtok segmentation fault
- Constructor for structs in C
- write() to stdout and printf output not interleaved?
- Implicit function declarations in C
- Using pointer to char array, values in that array can be accessed?
- How can I create a dynamically sized array of structs?
- how to stop a loop arduino
- How to normalize a mantissa
- Level vs Edge Trigger Network Event Mechanisms
- How to use shared memory with Linux in C
- When is it ok to use a global variable in C?