int main () { int * b; b = (int*) malloc (1); *b=110000; free (b); return 0; }
Why does a bunch happen when free (b);?
free (b);
IMO, heap damage already occurs at *b=110000;.
*b=110000;
malloc()An argument is the number of bytes to place. You need to use:
malloc()
b = (int*) malloc(sizeof(int));
You allocated a block too small, and then wrote more bytes than you allocated, which overwrites the accounting information next to the block, corrupting the heap.
* b = 110000; , int , . b = (int *) malloc (sizeof (int)), int * b char * b, malloced char *. , , 128 (- char) * b.
EDIT: - , - . .
*b=11000, free(b), , .
*b=11000
free(b)
( ) , . , malloc free ( ).
malloc
free
, , , .
char *, int *, -128 127 * b .
Source: https://habr.com/ru/post/1769328/More articles:Define DataGrid rows declaratively in XAML - c #How to add data to a DataGridView - c #Выполнение завершается с ошибкой через java -jar, в то время как тот же код работает отлично через eclipse - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1769326/converting-ms-access-to-mysql-with-relationships&usg=ALkJrhijbvGQm0vphDW1g6H3F1-HM60zhAResources for developing .NET applications for Windows Vista / 7? - .netReflective helper java libraries - javaCSS: div is fixed vertically, but moves horizontally - htmlUsing a conditional operator? to check for a null session variable - c #Java Textext Footer - javaSearch for std :: unordered_set by hash value and predicate - c ++All Articles