Changeset 5fd1894ad04542945430bed21cc582a937f8edcb

Show
Ignore:
Timestamp:
04/22/12 16:46:08 (2 years ago)
Author:
Theo Schlossnagle <jesus@omniti.com>
git-committer:
Theo Schlossnagle <jesus@omniti.com> 1335113168 -0400
git-parent:

[66cf6d4b55d526fdb6724e700480033f198045fa]

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

a variety of memory leaks in console commands.

Files:

Legend:

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

    r658ca09 r5fd1894  
    118118nc_attr_show(noit_console_closure_t ncct, const char *name, xmlNodePtr cnode, 
    119119             xmlNodePtr anode, const char *value) { 
    120   const char *cpath, *apath; 
    121   cpath = cnode ? (char *)xmlGetNodePath(cnode) : ""
    122   apath = anode ? (char *)xmlGetNodePath(anode) : ""
     120  char *cpath, *apath; 
     121  cpath = cnode ? (char *)xmlGetNodePath(cnode) : strdup("")
     122  apath = anode ? (char *)xmlGetNodePath(anode) : strdup("")
    123123  nc_printf(ncct, " %s: %s", name, value ? value : "[undef]"); 
    124124  if(value && cpath && apath) { 
     
    134134  } 
    135135  nc_write(ncct, "\n", 1); 
     136  if(cpath) free(cpath); 
     137  if(apath) free(apath); 
    136138} 
    137139static void  
     
    447449    } 
    448450    nc_printf(ncct, "==== %s ====\n", uuid_conf); 
     451    free(uuid_conf); 
    449452 
    450453#define MYATTR(a,n,b) _noit_conf_get_string(node, &(n), "@" #a, &(b)) 
     
    456459  INHERIT(a, anode, value); \ 
    457460  nc_attr_show(ncct, #a, node, anode, value); \ 
     461  if(value != NULL) free(value); \ 
    458462} while(0) 
    459463 
     
    464468      nc_printf(ncct, " name: %s [from module]\n", module ? module : "[undef]"); 
    465469    nc_attr_show(ncct, "module", node, mnode, module); 
     470    if(module) free(module); 
    466471    SHOW_ATTR(target); 
    467472    SHOW_ATTR(resolve_rtype); 
  • src/noit_console.c

    rdfec968 r5fd1894  
    299299  else if(i<0) nc_printf(ncct, "Error at offset: %d\n", 0-i); 
    300300  else noit_console_state_do(ncct, cnt, cmds); 
     301  while(cnt>0) free(cmds[--cnt]); 
    301302} 
    302303 
  • src/noit_console_complete.c

    r3e26749 r5fd1894  
    9797  noit_console_closure_t ncct; 
    9898  const LineInfo *li; 
    99   char **cmds, *curstr
     99  char **cmds, *curstr, *rv = NULL
    100100  int len, cnt = 32; 
    101101 
     
    107107 
    108108  cmds = alloca(32 * sizeof(*cmds)); 
     109  cmds[0] = NULL; 
    109110  (void) noit_tokenize(curstr, cmds, &cnt); 
    110111 
     
    112113 
    113114  if(!strlen(text)) { 
    114     cmds[cnt++] = ""
    115   } 
    116   if(cnt == 32) return NULL; 
    117   return noit_console_opt_delegate(ncct, ncct->state_stack, 
     115    cmds[cnt++] = strdup("")
     116  } 
     117  if(cnt != 32) 
     118    rv = noit_console_opt_delegate(ncct, ncct->state_stack, 
    118119                                   ncct->state_stack->state, 
    119120                                   cnt, cmds, state); 
     121  if(cmds[0]) while(cnt > 0) free(cmds[--cnt]); 
     122  return rv; 
    120123} 
    121124static int