Show
Ignore:
Timestamp:
02/20/05 16:29:15 (8 years ago)
Author:
minaguib
Message:

* New safe.c with safe_malloc, safe_strdup, safe_asprintf and safe_vasprintf with propper logging and exit when error. Replaced all instances of original with safe versions in all files
* Fix memory leak in iptables_fw_counters_update

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog/src/util.c

    r451 r467  
    4646#include <netdb.h> 
    4747 
     48#include "safe.h" 
    4849#include "util.h" 
    4950#include "conf.h" 
     
    101102        /* XXX Calling function is reponsible for free() */ 
    102103 
    103         h_addr = (struct in_addr *)malloc(sizeof(struct in_addr)); 
    104          
    105         if (h_addr == NULL) { 
    106                 debug(LOG_CRIT, "Failed to allocate memory for in_addr"); 
    107                 exit(1); 
    108         } 
     104        h_addr = safe_malloc(sizeof(struct in_addr)); 
    109105         
    110106        LOCK_GHBN(); 
     
    154150 
    155151    ip_str = (char *)inet_ntoa(in); 
    156     return strdup(ip_str); 
     152    return safe_strdup(ip_str); 
    157153} 
    158154