diff options
-rw-r--r-- | src/shared/dlt_common.c | 14 | ||||
-rw-r--r-- | tests/CMakeLists.txt | 2 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/shared/dlt_common.c b/src/shared/dlt_common.c index 1ae56c1..f8aa746 100644 --- a/src/shared/dlt_common.c +++ b/src/shared/dlt_common.c @@ -2392,9 +2392,11 @@ void dlt_buffer_write_block(DltBuffer *buf, int *write, const unsigned char *dat *write += (int) size; } else { - /* write two blocks */ - memcpy(buf->mem + *write, data, buf->size - (unsigned int) (*write)); - memcpy(buf->mem, data + buf->size - *write, size - buf->size + (unsigned int) (*write)); + if(buf->size > (unsigned int) (*write)) { + /* write two blocks */ + memcpy(buf->mem + *write, data, buf->size - (unsigned int) (*write)); + memcpy(buf->mem, data + buf->size - *write, size - buf->size + (unsigned int) (*write)); + } *write += (int) (size - buf->size); } } @@ -2417,9 +2419,11 @@ void dlt_buffer_read_block(DltBuffer *buf, int *read, unsigned char *data, unsig *read +=(int) size; } else { + if(buf->size > (unsigned int) (*read)) { /* read two blocks */ - memcpy(data, buf->mem + *read, buf->size - (unsigned int) (*read)); - memcpy(data + buf->size - *read, buf->mem, size - buf->size + (unsigned int) (*read)); + memcpy(data, buf->mem + *read, buf->size - (unsigned int) (*read)); + memcpy(data + buf->size - *read, buf->mem, size - buf->size + (unsigned int) (*read)); + } *read += (int) (size - buf->size); } } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 53b3949..3b7bbe4 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,6 +2,8 @@ add_compile_options(-isystem ${gtest_SOURCE_DIR}/include) configure_file(${PROJECT_SOURCE_DIR}/tests/testfile.dlt ${PROJECT_BINARY_DIR}/tests COPYONLY) +configure_file(${PROJECT_SOURCE_DIR}/tests/testfilter.txt ${PROJECT_BINARY_DIR}/tests COPYONLY) +configure_file(${PROJECT_SOURCE_DIR}/tests/testfile_filetransfer.txt ${PROJECT_BINARY_DIR}/tests COPYONLY) if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(LIBRARIES gtest gtest_main) |