diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2012-10-16 23:16:25 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2012-10-16 23:16:25 (GMT) |
commit | 84581571e138d5b7984b6d3198296013ec157d30 (patch) | |
tree | e4308cab1f1bf85feaaeb91e33874b7ef7ccbcbb /src/analysis | |
parent | 6f9563a0184e36fab8d0c2c38d151827784e331e (diff) |
Fixed many bugs using valgrind.
git-svn-id: svn://svn.gna.org/svn/chrysalide/trunk@269 abbe820e-26c8-41b2-8c08-b7b2b41f8b0a
Diffstat (limited to 'src/analysis')
-rw-r--r-- | src/analysis/binaries/file.c | 5 | ||||
-rw-r--r-- | src/analysis/binary.c | 14 |
2 files changed, 11 insertions, 8 deletions
diff --git a/src/analysis/binaries/file.c b/src/analysis/binaries/file.c index 0be1fd7..46307fb 100644 --- a/src/analysis/binaries/file.c +++ b/src/analysis/binaries/file.c @@ -162,7 +162,6 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) { GFileBinary *result; /* Adresse à retourner */ GLoadedBinary *loaded; /* Version parente */ - char *tmp; /* Nom de fichier modifiable */ result = g_object_new(G_TYPE_FILE_BINARY, NULL); loaded = G_LOADED_BINARY(result); @@ -171,10 +170,8 @@ GLoadedBinary *g_file_binary_new_from_file(const char *filename) result->filename = strdup(filename); - tmp = strdup(filename); - loaded->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, tmp, + loaded->format = G_EXE_FORMAT(load_new_format(FMT_EXEC, filename, &loaded->bin_data, &loaded->bin_length)); - free(tmp); if (loaded->format == NULL) { diff --git a/src/analysis/binary.c b/src/analysis/binary.c index fe8188b..d5bf029 100644 --- a/src/analysis/binary.c +++ b/src/analysis/binary.c @@ -733,7 +733,10 @@ GCodeBuffer *g_loaded_binary_get_decompiled_buffer(const GLoadedBinary *binary, { GCodeBuffer *result; /* Tampon à retourner */ - if (index >= binary->decbuf_count) + if (binary->decbuf_count == 0) + result = NULL; + + else if (index >= binary->decbuf_count) result = binary->dec_buffers[binary->defsrc]; else @@ -792,11 +795,14 @@ void ack_completed_disassembly(void/*GDelayedDisassembly*/ *disass, GLoadedBinar files = g_binary_format_get_source_files(G_BIN_FORMAT(binary->format), &binary->decbuf_count, &binary->defsrc); - binary->dec_buffers = (GCodeBuffer **)calloc(binary->decbuf_count, sizeof(GCodeBuffer *)); + if (binary->decbuf_count > 0) + { + binary->dec_buffers = (GCodeBuffer **)calloc(binary->decbuf_count, sizeof(GCodeBuffer *)); - for (i = 0; i < binary->decbuf_count; i++) - binary->dec_buffers[i] = decompile_all_from_file(binary, files[i]); + for (i = 0; i < binary->decbuf_count; i++) + binary->dec_buffers[i] = decompile_all_from_file(binary, files[i]); + } |