[splint-discuss] incomplete deallocation

Greg White pcguy11 at live.com
Fri Nov 7 18:28:54 PST 2008


Hi again,

I do the following in my code:

  n = malloc(sizeof(nk_hdr));
  if (n == NULL) {
    (void)snprintf(error, 50, "can't allocate memory for n\n");
    return -1;
  }
  memset(n, 0, sizeof(n));

nkhdr looks like:
typedef struct _nk_hdr {
  short int    name_len;
  short int    classname_len;
  unsigned char    *key_name; 
} nk_hdr;

when I do a free(n); 
splint says:
Only storage n->key_name (type unsigned char *) derived from
                    released storage is not released (memory leak): n
  A storage leak due to incomplete deallocation of a structure or deep pointer
  is suspected. Unshared storage that is reachable from a reference that is
  being deallocated has not yet been deallocated. Splint assumes when an object
  is passed as an out only void pointer that the outer object will be
  deallocated, but the inner objects will not. (Use -compdestroy to inhibit
  warning)

What did I do wrong?

Thanks,


_________________________________________________________________
Get 5 GB of storage with Windows Live Hotmail.
http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_5gb_112008


More information about the splint-discuss mailing list