diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2016-05-30 19:19:22 +0200 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2016-06-01 15:07:02 +0200 |
commit | 592631d9cb6c92434a717b5d05f8e48a5fb0d017 (patch) | |
tree | c4954c2772f7e16a408b7b98f506d2e9b15bfd95 /core/tee/tee_time_generic.c | |
parent | dbe42329afb1dd6593234fe37ea980edd8d169a6 (diff) |
core: fix undef behavior in tee_time_ta_set_offs()
Fixes undefined behavior in tee_time_ta_set_offs() when
tee_time_offs is initially NULL.
Reviewed-by: Joakim Bech <joakim.bech@linaro.org>
Tested-by: Jens Wiklander <jens.wiklander@linaro.org> (QEMU, FVP)
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'core/tee/tee_time_generic.c')
-rw-r--r-- | core/tee/tee_time_generic.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/core/tee/tee_time_generic.c b/core/tee/tee_time_generic.c index b0215916..54180a40 100644 --- a/core/tee/tee_time_generic.c +++ b/core/tee/tee_time_generic.c @@ -72,12 +72,9 @@ static TEE_Result tee_time_ta_set_offs(const TEE_UUID *uuid, } n = tee_time_num_offs + 1; - o = malloc(n * sizeof(struct tee_ta_time_offs)); - if (o == NULL) + o = realloc(tee_time_offs, n * sizeof(struct tee_ta_time_offs)); + if (!o) return TEE_ERROR_OUT_OF_MEMORY; - memcpy(o, tee_time_offs, - tee_time_num_offs * sizeof(struct tee_ta_time_offs)); - free(tee_time_offs); tee_time_offs = o; tee_time_offs[tee_time_num_offs].uuid = *uuid; tee_time_offs[tee_time_num_offs].offs = *offs; |