In this section:

Overview

This error is generated whenever an attempt is made to de-allocate memory by means of an uninitialized pointer.

CodeDescriptionEnabledReportedPlatform
FREE_UNINIT_PTR

Freeing uninitialized pointer

(tick)RuntimeWindows/Unix


Problem

This code attempts to free a pointer which has not been initialized.

/*
 * File: freeuptr.c
 */
main()
{
	char *a;
	free(a);
	return (0);
}

Diagnosis at Runtime

[freeuptr.c:7] **FREE_UNINIT_PTR**
>>		 free(a);
Freeing uninitialized pointer: a
Stack trace where the error occurred:
		main() freeuptr.c, 7
**Memory corrupted. Program may crash!!**
  • Line 2: Source file and line at which the problem was detected.
  • Line 3: Description of the problem and the expression that is in error.
  • Line 5: Stack trace showing the function call sequence leading to the error.
  • Line 6: Informational message indicating that a serious error has occurred which may cause the program to crash.

Repair

Some systems appear to allow this operation, since they will refuse to free memory that was not dynamically allocated. Relying on this behavior is very dangerous, however, since an uninitialized pointer may “accidentally” point to a block of memory that was dynamically allocated, but should not be freed.

  • No labels