
本文共 2879 字,大约阅读时间需要 9 分钟。
malloc(0) ���������������
��������� size ��� 0 ������malloc() ��������������������������������������������������������� C ��������������������� Attritionedoon documentations ���������������������
������������ size ��� 0���malloc() ������������������������������
��������������� pointer
������ pointer ������������������������������������ calloc(0, ...)��������������������������������� pointer��������������� free() ��������������������������� pointer ������������������������������������������������������������������ malloc(0) ������������������������������������������������������������ NULL pointer������������������������������������������
������������������������
��������������������������������� NULL��� pointer������������ pointer ���������������������
- ������������������������������������������ buffer overflow���
- ������������������������������������������������������������������������������������
- ��������������������������������������������������������� malloc(0)��������������������� nil ��� ������������������������
������������
���������������������������������������������������������������������
#include#include int main(int argc, char **argv) { unsigned char * p = malloc(0); if (p == NULL) { printf("null pointer\n"); } else { printf("non-null pointer\n"); printf("address of malloc(0) is %p, content of malloc(0) is: %s\n", p, (char *)p); free(p); } return 0;}
��������������������������������������������������������������������������������������������������������������������������������������������������������������������� because ������������������������������
������������������������������������������������������������������������������������������������������������������������������������ pointer ��������������������������������������������������� runtime errors���
man ������������������������
������ man pages���malloc(0) ������������������������
- ��������������� size ��� 0 ������������ NULL ������������������ pointer������������������������ free() ���������������
- ���������������������������������������������������������������������������������������������������������������
������������
������ malloc(0) callbacks in C standards ���������������������������������������������������������������������������������������������
������
malloc(0) ��������������� NULL ��������� pointer��������������������������������������������������������������������������������� C ���������������������������������������������������������������
发表评论
最新留言
关于作者
