Changeset 3123


Ignore:
Timestamp:
Mar 27, 2010 3:08:08 AM (10 years ago)
Author:
bennylp
Message:

Fixed ticket #1048: Memory leak in enum_ipv4_ipv6_interface (ip_helper_win32.c) (thanks Andrey Mamchur for the report)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/src/pj/ip_helper_win32.c

    r3040 r3123  
    275275    pj_uint8_t buffer[600]; 
    276276    IP_ADAPTER_ADDRESSES *adapter = (IP_ADAPTER_ADDRESSES*)buffer; 
     277    void *adapterBuf = NULL; 
    277278    ULONG size = sizeof(buffer); 
    278279    ULONG flags; 
     
    288289        if (rc == ERROR_BUFFER_OVERFLOW) { 
    289290            /* Retry with larger memory size */ 
    290             adapter = (IP_ADAPTER_ADDRESSES*) malloc(size); 
     291            adapterBuf = malloc(size); 
     292            adapter = (IP_ADAPTER_ADDRESSES*) adapterBuf; 
    291293            if (adapter != NULL) 
    292294                rc = MyGetAdapterAddresses(af, flags, NULL, adapter, &size); 
     
    294296 
    295297        if (rc != ERROR_SUCCESS) { 
    296             if (adapter != (IP_ADAPTER_ADDRESSES*)buffer) 
    297                 free(adapter); 
     298            if (adapterBuf) 
     299                free(adapterBuf); 
    298300            return PJ_RETURN_OS_ERROR(rc); 
    299301        } 
     
    351353    } 
    352354 
    353     if (adapter != (IP_ADAPTER_ADDRESSES*)buffer) 
    354         free(adapter); 
     355    if (adapterBuf) 
     356        free(adapterBuf); 
    355357 
    356358    *p_cnt = i; 
Note: See TracChangeset for help on using the changeset viewer.