From f5ac2a19c851dba5009799bf965e365376e048bb Mon Sep 17 00:00:00 2001 From: Giulio Gaio <giulio.gaio@elettra.eu> Date: Thu, 4 May 2023 11:30:40 +0200 Subject: [PATCH] Added checks on data size --- src/DataVampire.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/DataVampire.cpp b/src/DataVampire.cpp index 597532f..57704ae 100644 --- a/src/DataVampire.cpp +++ b/src/DataVampire.cpp @@ -2031,6 +2031,23 @@ void DataVampire::store_data(Tango::DeviceData *cmd_value, int32_t num_samples, __FUNCTION__); } + if (((num_cols * num_rows * num_samples) > val.size()) && (*attr_PostAcqRoi_read == true)) { + Tango::Except::throw_exception ( + (const char *)"Failed to store data", + (const char *)"Data size too large", + __FUNCTION__); + } + + if ((*attr_PostAcqRoi_read == true) && (roi_dim == 4)) { + if ((num_cols * num_rows * num_samples) != (*attr_Width_read * *attr_Height_read * num_samples)) { + Tango::Except::throw_exception ( + (const char *)"Failed to store data", + (const char *)"Width/Height mismatch with image size", + __FUNCTION__); + } + + } + // reallocate buffer if (val.size() != cache_buffer[cache_idx].data_size) { cache_buffer[cache_idx].databuf = (double *)realloc(cache_buffer[cache_idx].databuf, val.size() * sizeof(double)); -- GitLab