home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lclint.zip / lclint-2_3h-os2-bin.zip / test / merge.c < prev    next >
Text File  |  1997-09-03  |  659b  |  56 lines

  1. /*@null@*/ int *x;
  2.  
  3. void f1 (void)
  4. {
  5.   int *y = x;
  6.  
  7.   if (3 > 4)
  8.     {
  9.       ;
  10.     }
  11.   else
  12.     {
  13.       x = NULL;
  14.       if (y != NULL) free (y);
  15.     }
  16.   /* y is unuseable...but no error yet */
  17. }
  18.  
  19. void f2 (void)
  20. {
  21.   int *y = x;
  22.  
  23.   if (3 > 4)
  24.     {
  25.       ;
  26.     }
  27.   else
  28.     {
  29.       x = NULL;
  30.       if (y != NULL) free (y);
  31.     }
  32.  
  33.   *y = 23; /* 1. Variable y used in inconsistent state */
  34. }          /* 2. Dereference of possibly null pointer y: *y */
  35.  
  36. void f3 (void)
  37. {
  38.   int *y = x;
  39.  
  40.   if (3 > 4)
  41.     {
  42.       ;
  43.     }
  44.   else
  45.     {
  46.       x = NULL;
  47.       if (y != NULL) free (y);
  48.     }
  49.  
  50.   y = x;
  51.   *y = 23; /* 3. Dereference of possibly null pointer y: *y */
  52. }
  53.  
  54.  
  55.  
  56.