Changeset 52 for trunk


Ignore:
Timestamp:
08/08/05 20:43:07 (19 years ago)
Author:
tim
Message:

fixed a double-free bug which FreeBSD (but not Linux) catches and bails on.

other minor tweaks

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/void_stack.c

    r38 r52  
    9090void void_stack_destroy(void_stack* stack)
    9191{
     92  free(stack->elements);
    9293  free(stack);
    9394}
     
    99100  for(i=0; i < stack->top; i++)
    100101    free(stack->elements[i]);
     102  free(stack->elements);
    101103  free(stack);
    102104}
     
    127129  if(stack->top > 0)
    128130  {
    129     ret_val = stack->elements[--stack->top];
     131    ret_val = stack->elements[--(stack->top)];
    130132    stack->elements[stack->top] = NULL;
    131133  }
  • trunk/src/reglookup.c

    r48 r52  
    640640void printKeyTree(REGF_FILE* f, void_stack* nk_stack, char* prefix)
    641641{
    642   REGF_NK_REC* cur;
    643   REGF_NK_REC* sub;
     642  REGF_NK_REC* cur = NULL;
     643  REGF_NK_REC* sub = NULL;
    644644  char* path = NULL;
    645645  char* val_path = NULL;
     
    703703                 void_stack* path_stack)
    704704{
    705   REGF_NK_REC* sub;
    706   REGF_NK_REC* cur;
     705  REGF_NK_REC* sub = NULL;
     706  REGF_NK_REC* cur = NULL;
    707707  void_stack* sub_nk_stack;
    708708  char* prefix;
     709  uint32 prefix_len;
    709710  char* cur_str = NULL;
    710711  bool found_cur = true;
     
    765766      sub_nk_stack = void_stack_new(1024);
    766767      void_stack_push(sub_nk_stack, sub);
    767       void_stack_push(nk_stack, sub);
    768768      prefix = stack2Path(nk_stack);
     769      prefix_len = strlen(prefix);
     770      prefix = realloc(prefix, prefix_len+strlen(sub->keyname)+2);
     771      if(prefix == NULL)
     772        return -1;
     773      strcat(prefix, "/");
     774      strcat(prefix, sub->keyname);
    769775      printKeyTree(f, sub_nk_stack, prefix);
    770776      return 0;
Note: See TracChangeset for help on using the changeset viewer.