diff options
author | Lassi Marttala <lassi.lm.marttala@partner.bmw.com> | 2012-02-21 13:02:16 +0100 |
---|---|---|
committer | Christian Muck <christian.muck@bmw.de> | 2012-04-04 14:30:43 +0200 |
commit | 5909561a7ac82ba25694321f3ffa37c83f7e085f (patch) | |
tree | ba7c99792490570dc3a367600a4ad7fba79e6876 /src/daemon/dlt-daemon.c | |
parent | aea3ecd7cbbdff54dc061357e96cf606f9a52dea (diff) | |
download | DLT-daemon-5909561a7ac82ba25694321f3ffa37c83f7e085f.tar.gz |
GENDLT-15, Safe re-allocations for databuffer.
Signed-off-by: Christian Muck <christian.muck@bmw.de>
Diffstat (limited to 'src/daemon/dlt-daemon.c')
-rwxr-xr-x | src/daemon/dlt-daemon.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/daemon/dlt-daemon.c b/src/daemon/dlt-daemon.c index 79d8bea..04612bb 100755 --- a/src/daemon/dlt-daemon.c +++ b/src/daemon/dlt-daemon.c @@ -1527,11 +1527,15 @@ int dlt_daemon_process_user_message_register_context(DltDaemon *daemon, DltDaemo } msg.datasize = sizeof(DltServiceGetLogInfoRequest); - if (msg.databuffer) + if (msg.databuffer && (msg.databuffersize < msg.datasize)) { free(msg.databuffer); + msg.databuffer=0; + } + if (msg.databuffer == 0){ + msg.databuffer = (uint8_t *) malloc(msg.datasize); + msg.databuffersize = msg.datasize; } - msg.databuffer = (uint8_t *) malloc(msg.datasize); if (msg.databuffer==0) { dlt_log(LOG_ERR,"Can't allocate buffer for get log info message\n"); |