Changeset 181


Ignore:
Timestamp:
03/15/10 12:50:36 (15 years ago)
Author:
tim
Message:

fixed memory management issues and a talloc_free() of an uninitialized pointer

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/regfi.c

    r180 r181  
    12891289        }
    12901290      }
    1291       talloc_reference(nk, nk->values);
     1291      talloc_steal(nk, nk->values);
    12921292    }
    12931293  }
     
    13191319        nk->num_subkeys = 0;
    13201320      }
    1321       talloc_reference(nk, nk->subkeys);
     1321      talloc_steal(nk, nk->subkeys);
    13221322    }
    13231323  }
     
    14421442
    14431443  /* In this case, we want file_cb to be freed when ret_val is */
    1444   talloc_reference(ret_val, file_cb);
     1444  talloc_steal(ret_val, file_cb);
    14451445  return ret_val;
    14461446
     
    14951495  if(rb->hbins == NULL)
    14961496    goto fail;
    1497   talloc_reference(rb, rb->hbins);
     1497  talloc_steal(rb, rb->hbins);
    14981498
    14991499  rla = true;
     
    15041504    rla = range_list_add(rb->hbins, hbin->file_off, hbin->block_size, hbin);
    15051505    if(rla)
    1506       talloc_reference(rb->hbins, hbin);
     1506      talloc_steal(rb->hbins, hbin);
    15071507
    15081508    hbin_off = hbin->file_off + hbin->block_size;
     
    16551655    return NULL;
    16561656  }
     1657  ret_val->cur_key = root;
     1658  talloc_steal(ret_val, root);
    16571659
    16581660  ret_val->key_positions = void_stack_new(REGFI_MAX_DEPTH);
     
    16621664    return NULL;
    16631665  }
    1664   talloc_reference(ret_val, ret_val->key_positions);
     1666  talloc_steal(ret_val, ret_val->key_positions);
    16651667
    16661668  ret_val->f = file;
    1667   ret_val->cur_key = root;
    16681669  ret_val->cur_subkey = 0;
    16691670  ret_val->cur_value = 0;
     
    17101711    return false;
    17111712  }
    1712   talloc_reference(i, subkey);
     1713  talloc_steal(i, subkey);
    17131714
    17141715  i->cur_key = subkey;
     
    19951996  ret_val->raw = raw;
    19961997  ret_val->size = parse_length;
    1997   talloc_reference(ret_val, raw);
     1998  talloc_steal(ret_val, raw);
    19981999
    19992000  interpreted = talloc_array(NULL, char, parse_length);
     
    20152016    interpreted = talloc_realloc(NULL, interpreted, char, conv_size);
    20162017    ret_val->interpreted = interpreted;
    2017     talloc_reference(ret_val, interpreted);
     2018    talloc_steal(ret_val, interpreted);
    20182019  }
    20192020
     
    20952096    return NULL;
    20962097 
    2097   talloc_reference(ret_val, raw_data.buf);
     2098  talloc_steal(ret_val, raw_data.buf);
    20982099  ret_val->raw = raw_data.buf;
    20992100  ret_val->size = raw_data.len;
     
    21502151    data->interpreted.string = tmp_str;
    21512152    data->interpreted_size = tmp_size;
    2152     talloc_reference(data, tmp_str);
     2153    talloc_steal(data, tmp_str);
    21532154    break;
    21542155
     
    22352236    /* XXX: how meaningful is this?  should we store number of strings instead? */
    22362237    data->interpreted_size = tmp_size;
    2237     talloc_reference(tmp_array, tmp_str);
    2238     talloc_reference(data, tmp_array);
     2238    talloc_steal(tmp_array, tmp_str);
     2239    talloc_steal(data, tmp_array);
    22392240    break;
    22402241
     
    24192420REGFI_HBIN* regfi_parse_hbin(REGFI_FILE* file, uint32_t offset, bool strict)
    24202421{
    2421   REGFI_HBIN *hbin;
     2422  REGFI_HBIN* hbin = NULL;
    24222423  uint8_t hbin_header[REGFI_HBIN_HEADER_SIZE];
    24232424  uint32_t length;
  • trunk/src/reglookup-recover.c

    r178 r181  
    3535bool print_leftover = false;
    3636bool print_parsedraw = false;
    37 char* registry_file = NULL;
     37const char* registry_file = NULL;
    3838
    3939#include "common.c"
     
    818818    }
    819819  }
    820   /*test_offset = strtol(argv[argi++], NULL, 16);*/
    821 
    822   if((registry_file = strdup(argv[argi])) == NULL)
    823     bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Memory allocation problem.\n");
     820  registry_file = argv[argi];
    824821
    825822  fd = openHive(registry_file);
  • trunk/src/reglookup.c

    r178 r181  
    4040char* path_filter = NULL;
    4141int type_filter;
    42 char* registry_file = NULL;
     42const char* registry_file = NULL;
    4343
    4444/* Other globals */
     
    617617    }
    618618  }
    619   if((registry_file = strdup(argv[argi])) == NULL)
    620     bailOut(REGLOOKUP_EXIT_OSERR, "ERROR: Memory allocation problem.\n");
     619  registry_file = argv[argi];
    621620
    622621  fd = openHive(registry_file);
Note: See TracChangeset for help on using the changeset viewer.