Show
Ignore:
Timestamp:
04/22/12 18:43:28 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1335120208 -0400
git-parent:

[1dbb45b9deca8465c32394889ee40088e6297634]

git-author:
Theo Schlossnagle <jesus@omniti.com> 1335120208 -0400
Message:

various leaks in the console driver and our fork of libedit. tgetent() still appears to leak, but that might be an ncurses bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/noit_console.c

    r5fd1894 r60aa58b  
    170170int 
    171171nc_write(noit_console_closure_t ncct, const void *buf, int len) { 
     172  if(len == 0) return 0; 
    172173  if(!ncct->outbuf_allocd) { 
    173174    ncct->outbuf = malloc(len); 
     
    197198} 
    198199void 
    199 noit_console_closure_free(noit_console_closure_t ncct) { 
     200noit_console_closure_free(void *vncct) { 
     201  noit_console_closure_t ncct = (noit_console_closure_t) vncct; 
    200202  noit_log_stream_t lf; 
     203  noitL(noit_debug, "ncct free(%p)\n", (void *)ncct); 
    201204  if(ncct->el) el_end(ncct->el); 
    202   if(ncct->hist) history_end(ncct->hist); 
     205  if(ncct->hist) { 
     206    history_end(ncct->hist); 
     207    noitL(noit_debug, "ncct free->hist(%p)\n", (void *)ncct->hist); 
     208    free(ncct->hist); 
     209  } 
    203210  if(ncct->pty_master >= 0) close(ncct->pty_master); 
    204211  if(ncct->pty_slave >= 0) close(ncct->pty_slave); 
     
    210217    tmp = ncct->state_stack; 
    211218    ncct->state_stack = tmp->last; 
     219    if(tmp->name) free(tmp->name); 
    212220    free(tmp); 
    213221  } 
     
    357365    /* This removes the log feed which is important to do before calling close */ 
    358366    eventer_remove_fd(e->fd); 
    359     if(ncct) noit_console_closure_free(ncct); 
    360367    if(ac) acceptor_closure_free(ac); 
    361368    e->opset->close(e->fd, &newmask, e); 
     
    365372  if(!ac->service_ctx) { 
    366373    ncct = ac->service_ctx = noit_console_closure_alloc(); 
     374    noitL(noit_debug, "ncct alloc() -> %p\n", (void *)ncct); 
     375    ac->service_ctx_free = noit_console_closure_free; 
    367376  } 
    368377  if(!ncct->initialized) { 
     
    447456    if(len == 0 || (len < 0 && errno != EAGAIN)) { 
    448457      eventer_remove_fd(e->fd); 
    449       if(ncct) noit_console_closure_free(ncct); 
    450458      if(ac) acceptor_closure_free(ac); 
    451459      e->opset->close(e->fd, &newmask, e); 
  • src/noit_console_telnet.c

    rd8d5d86 r60aa58b  
    14201420             */ 
    14211421 
     1422            memset(&ws, 0, sizeof(ws)); 
    14221423            ws.ws_col = parm1; 
    14231424            ws.ws_row = parm2; 
  • src/noitedit/history.c

    r234b2c6 r60aa58b  
    496496        if (h->h_next == history_def_next) 
    497497                history_def_clear(h->h_ref, &ev); 
     498  h_free(h->h_ref); 
    498499} 
    499500 
  • src/noitedit/key.c

    r52b8bc4 r60aa58b  
    127127        el_free((ptr_t) el->el_key.buf); 
    128128        el->el_key.buf = NULL; 
    129         /* XXX: provide a function to clear the keys */ 
     129        if(el->el_key.map) node__put(el, el->el_key.map); 
    130130        el->el_key.map = NULL; 
    131131} 
  • src/noitedit/term.c

    rb5eb9e5 r60aa58b  
    376376        el->el_term.t_cap = NULL; 
    377377        el->el_term.t_loc = 0; 
     378        el_free((ptr_t) el->el_term.t_fkey); 
     379        el->el_term.t_fkey = NULL; 
    378380        el_free((ptr_t) el->el_term.t_str); 
    379381        el->el_term.t_str = NULL; 
  • src/utils/noit_log.c

    r4741bb2 r60aa58b  
    678678noit_log_stream_t 
    679679noit_log_stream_new_on_fd(const char *name, int fd, noit_hash_table *config) { 
     680  char *lsname; 
    680681  noit_log_stream_t ls; 
    681682  ls = calloc(1, sizeof(*ls)); 
     
    690691   * for an explanation. 
    691692   */ 
     693  lsname = strdup(ls->name); 
    692694  if(noit_hash_store(&noit_loggers, 
    693                      strdup(ls->name), strlen(ls->name), ls) == 0) { 
     695                     lsname, strlen(ls->name), ls) == 0) { 
     696    free(lsname); 
    694697    free(ls->name); 
    695698    free(ls); 
     
    745748     * under us. 
    746749     */ 
     750    char *lsname; 
     751    lsname = strdup(ls->name); 
    747752    if(noit_hash_store(&noit_loggers, 
    748                        strdup(ls->name), strlen(ls->name), ls) == 0) 
     753                       lsname, strlen(ls->name), ls) == 0) { 
     754      free(lsname); 
    749755      goto freebail; 
     756    } 
    750757    ls->lock = calloc(1, sizeof(*ls->lock)); 
    751758    noit_log_init_rwlock(ls); 
     
    776783void 
    777784noit_log_stream_remove(const char *name) { 
    778   noit_hash_delete(&noit_loggers, name, strlen(name), NULL, NULL); 
     785  noit_hash_delete(&noit_loggers, name, strlen(name), free, NULL); 
    779786} 
    780787 
     
    850857    if(ls->name) free(ls->name); 
    851858    if(ls->path) free(ls->path); 
     859    if(ls->type) free(ls->type); 
    852860    while(ls->outlets) { 
    853861      node = ls->outlets->next;