summaryrefslogtreecommitdiff
path: root/src/target
diff options
context:
space:
mode:
authoroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-20 10:10:54 +0000
committeroharboe <oharboe@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-20 10:10:54 +0000
commit0485363c457fd42f38e94ee6b7190c89a4aa762f (patch)
tree0816f27dc3751362b13bc08e3c0580173eb1f0cb /src/target
parent0989c374e91fb7c743c8f791e55fcca935351e9d (diff)
downloadopenocd_libswd-0485363c457fd42f38e94ee6b7190c89a4aa762f.tar.gz
openocd_libswd-0485363c457fd42f38e94ee6b7190c89a4aa762f.tar.bz2
openocd_libswd-0485363c457fd42f38e94ee6b7190c89a4aa762f.tar.xz
openocd_libswd-0485363c457fd42f38e94ee6b7190c89a4aa762f.zip
Edgar Grimberg fixes some memory handling issues and
a problem with arm7_9_debug_entry not executing a code path upon crashes. git-svn-id: svn://svn.berlios.de/openocd/trunk@669 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/target')
-rw-r--r--src/target/arm7_9_common.c2
-rw-r--r--src/target/etm.c8
-rw-r--r--src/target/image.c11
3 files changed, 20 insertions, 1 deletions
diff --git a/src/target/arm7_9_common.c b/src/target/arm7_9_common.c
index 740cf923..249d8d4c 100644
--- a/src/target/arm7_9_common.c
+++ b/src/target/arm7_9_common.c
@@ -1111,7 +1111,7 @@ int arm7_9_debug_entry(target_t *target)
return ERROR_FAIL;
/* exceptions other than USR & SYS have a saved program status register */
- if ((armv4_5_mode_to_number(armv4_5->core_mode) != ARMV4_5_MODE_USR) && (armv4_5_mode_to_number(armv4_5->core_mode) != ARMV4_5_MODE_SYS))
+ if ((armv4_5->core_mode != ARMV4_5_MODE_USR) && (armv4_5->core_mode != ARMV4_5_MODE_SYS))
{
u32 spsr;
arm7_9->read_xpsr(target, &spsr, 1);
diff --git a/src/target/etm.c b/src/target/etm.c
index 8e39a4f6..afea12b3 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -1645,12 +1645,14 @@ int handle_etm_load_command(struct command_context_s *cmd_ctx, char *cmd, char *
if (file.size % 4)
{
command_print(cmd_ctx, "size isn't a multiple of 4, no valid trace data");
+ fileio_close(&file);
return ERROR_OK;
}
if (etm_ctx->trace_depth > 0)
{
free(etm_ctx->trace_data);
+ etm_ctx->trace_data = NULL;
}
fileio_read_u32(&file, &etm_ctx->capture_status);
@@ -1659,6 +1661,12 @@ int handle_etm_load_command(struct command_context_s *cmd_ctx, char *cmd, char *
fileio_read_u32(&file, &etm_ctx->trace_depth);
etm_ctx->trace_data = malloc(sizeof(etmv1_trace_data_t) * etm_ctx->trace_depth);
+ if(etm_ctx->trace_data == NULL)
+ {
+ command_print(cmd_ctx, "not enough memory to perform operation");
+ fileio_close(&file);
+ return ERROR_OK;
+ }
for (i = 0; i < etm_ctx->trace_depth; i++)
{
diff --git a/src/target/image.c b/src/target/image.c
index 72a3828c..16f32867 100644
--- a/src/target/image.c
+++ b/src/target/image.c
@@ -347,6 +347,12 @@ int image_elf_read_headers(image_t *image)
elf->header = malloc(sizeof(Elf32_Ehdr));
+ if(elf->header == NULL)
+ {
+ LOG_ERROR("insufficient memory to perform operation ");
+ return ERROR_FILEIO_OPERATION_FAILED;
+ }
+
if ((retval = fileio_read(&elf->fileio, sizeof(Elf32_Ehdr), (u8*)elf->header, &read_bytes)) != ERROR_OK)
{
LOG_ERROR("cannot read ELF file header, read failed");
@@ -392,6 +398,11 @@ int image_elf_read_headers(image_t *image)
}
elf->segments = malloc(elf->segment_count*sizeof(Elf32_Phdr));
+ if(elf->segments == NULL)
+ {
+ LOG_ERROR("insufficient memory to perform operation ");
+ return ERROR_FILEIO_OPERATION_FAILED;
+ }
if ((retval = fileio_read(&elf->fileio, elf->segment_count*sizeof(Elf32_Phdr), (u8*)elf->segments, &read_bytes)) != ERROR_OK)
{