2
0
forked from Ivasoft/DSView

fix: The hex format string of decoder result, max length up to 256

This commit is contained in:
dreamsourcelabTAI
2023-05-15 18:58:28 +08:00
parent e9478aa926
commit 2067d5973b
7 changed files with 22 additions and 12 deletions

View File

@@ -87,8 +87,16 @@ Annotation::Annotation(const srd_proto_data *const pdata, DecoderStatus *status)
//get numeric data
if (pda->str_number_hex[0]){
strcpy(resItem->str_number_hex, pda->str_number_hex);
resItem->is_numeric = true;
int str_len = strlen(pda->str_number_hex);
if (str_len <= DECODER_MAX_DATA_BLOCK_LEN){
resItem->str_number_hex = (char*)malloc(str_len + 1);
if (resItem->str_number_hex != NULL){
strcpy(resItem->str_number_hex, pda->str_number_hex);
resItem->is_numeric = true;
}
}
}
_status->m_bNumeric |= resItem->is_numeric;

View File

@@ -117,6 +117,7 @@ int AnnotationResTable::MakeIndex(const std::string &key, AnnotationSourceItem*
item->cur_display_format = -1;
item->is_numeric = false;
item->str_number_hex = NULL;
newItem = item;
int dex = m_indexs.size();
@@ -331,6 +332,8 @@ void AnnotationResTable::reset()
{
//release all resource
for (auto p : m_resourceTable){
if (p->str_number_hex)
free(p->str_number_hex);
delete p;
}
m_resourceTable.clear();

View File

@@ -26,14 +26,14 @@
#include <vector>
#include <QString>
#define DECODER_MAX_DATA_BLOCK_LEN 35
#define DECODER_MAX_DATA_BLOCK_LEN 256
#define CONVERT_STR_MAX_LEN 150
struct AnnotationSourceItem
{
bool is_numeric;
char str_number_hex[DECODER_MAX_DATA_BLOCK_LEN]; //numerical value hex format string
long long numberic_value;
char *str_number_hex; //numerical value hex format string
std::vector<QString> src_lines; //the origin source string lines
std::vector<QString> cvt_lines; //the converted to bin/hex/oct format string lines
int cur_display_format; //current format as bin/ex/oct..., init with -1

View File

@@ -1704,13 +1704,11 @@ namespace pv
_protocol_widget->update_view_status();
break;
case DSV_MSG_COLLECT_END:
dsv_info("Mainwindow:DSV_MSG_COLLECT_END");
case DSV_MSG_COLLECT_END:
prgRate(0);
_view->repeat_unshow();
_view->on_state_changed(true);
_protocol_widget->update_view_status();
dsv_info("Mainwindow-end:DSV_MSG_COLLECT_END");
_protocol_widget->update_view_status();
break;
case DSV_MSG_END_COLLECT_WORK: