mirror of
https://github.com/DreamSourceLab/DSView.git
synced 2025-01-23 13:42:55 +08:00
fix: The hex format string of decoder result, max length up to 256
This commit is contained in:
parent
e9478aa926
commit
2067d5973b
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -1705,12 +1705,10 @@ namespace pv
|
||||
break;
|
||||
|
||||
case DSV_MSG_COLLECT_END:
|
||||
dsv_info("Mainwindow: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");
|
||||
break;
|
||||
|
||||
case DSV_MSG_END_COLLECT_WORK:
|
||||
|
@ -369,6 +369,6 @@
|
||||
},
|
||||
{
|
||||
"id": "IDS_MSG_DEVICE_BUSY_SWITCH_FAILED",
|
||||
"text": "设置在使用中,切换失败!"
|
||||
"text": "设备在使用中,切换失败!"
|
||||
}
|
||||
]
|
@ -26,7 +26,7 @@
|
||||
#include <glib.h>
|
||||
#include <log/xlog.h>
|
||||
|
||||
#define DECODE_NUM_HEX_MAX_LEN 35
|
||||
#define DECODE_NUM_HEX_MAX_LEN 256
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -132,6 +132,7 @@ static int py_parse_ann_data(PyObject *list_obj, char ***out_strv, int list_size
|
||||
nstr = strlen(str) - 1;
|
||||
if (nstr > 0 && nstr < DECODE_NUM_HEX_MAX_LEN){
|
||||
strcpy(hex_str_buf, str + 1);
|
||||
|
||||
str[0] = '\n'; //set ignore flag
|
||||
str[1] = 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user