Changeset 27

Show
Ignore:
Timestamp:
04/29/08 15:08:04 (7 months ago)
Author:
jtang
Message:

Fix possible memory leak if realloc() failed.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libsipc/src/sipc_mqueue.c

    r21 r27  
    243243                alloc_sz += next_alloc_sz(*len, recv_sz, msgtxt_sz, sipc->msg_len); 
    244244 
    245                 *data = realloc(*data, alloc_sz); 
    246                 if (!(*data)) { 
     245                char *tdata = realloc(*data, alloc_sz); 
     246                if (!(*tdata)) { 
    247247                        sipc_error(sipc, "%s\n", "Out of memory"); 
     248                        free(*data); 
     249                        *data = NULL; 
    248250                        goto err; 
    249251                } 
     252                *data = tdata; 
    250253                 
    251254                /* memset(*data+idx, 0x0, recv_sz); */