home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / EXAMPLES / MSC / BUG_MEM.C next >
Encoding:
C/C++ Source or Header  |  1993-01-29  |  372 b   |  21 lines

  1. // BUG_MEM.C -- Program with an (obvious bug) -- fails to
  2. //        check for NULL return from malloc().
  3. //
  4. //    By linking with -OFFSET 1000h we can have 386|DOS-Extender 
  5. //    automatically detect the resulting NULL pointer dereference
  6. //    for us.
  7. //
  8. #include <malloc.h>
  9.  
  10. int main()
  11. {
  12.     char *p;
  13.  
  14.     for (;;)
  15.     {
  16.         p  = malloc(0x10000);
  17.         *p = 'x';
  18.     }
  19.     return 0;
  20. }
  21.