diff --git a/libsigrok4DSL/dsdevice.c b/libsigrok4DSL/dsdevice.c index 4c9fdef2..28c98215 100644 --- a/libsigrok4DSL/dsdevice.c +++ b/libsigrok4DSL/dsdevice.c @@ -201,8 +201,8 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int mode, int status, sdi->version = g_strdup(version); } - if (model && *model){ - strncpy(sdi->name, model, sizeof(sdi->name)-1); + if (model && *model){ + sdi->name = g_strdup(model); } return sdi; @@ -236,6 +236,7 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi) safe_free(sdi->vendor); safe_free(sdi->version); safe_free(sdi->path); + safe_free(sdi->name); g_free(sdi); } diff --git a/libsigrok4DSL/libsigrok-internal.h b/libsigrok4DSL/libsigrok-internal.h index 1b9b30be..67f79bdb 100644 --- a/libsigrok4DSL/libsigrok-internal.h +++ b/libsigrok4DSL/libsigrok-internal.h @@ -146,7 +146,7 @@ struct sr_dev_inst { ds_device_handle handle; /** device name. */ - char name[50]; + char *name; char *path; diff --git a/libsigrok4DSL/libsigrok.h b/libsigrok4DSL/libsigrok.h index 1163499c..a2b470cf 100644 --- a/libsigrok4DSL/libsigrok.h +++ b/libsigrok4DSL/libsigrok.h @@ -1328,13 +1328,13 @@ typedef unsigned long long ds_device_handle; struct ds_device_base_info { ds_device_handle handle; - char name[50]; + char name[150]; }; struct ds_device_full_info { ds_device_handle handle; - char name[50]; + char name[150]; char path[256]; //file path char driver_name[20]; int dev_type; // enum sr_device_type diff --git a/libsigrok4DSL/session_driver.c b/libsigrok4DSL/session_driver.c index 4becded1..7f840376 100644 --- a/libsigrok4DSL/session_driver.c +++ b/libsigrok4DSL/session_driver.c @@ -1459,7 +1459,7 @@ static int dev_acquisition_start(struct sr_dev_inst *sdi, void *cb_data) SR_PRIV int sr_new_virtual_device(const char *filename, struct sr_dev_inst **out_di) { struct sr_dev_inst *sdi; - char short_name[50]; + char short_name[150]; GKeyFile *kf; char **sections, **keys, *metafile, *val; int mode = LOGIC; @@ -1560,7 +1560,7 @@ SR_PRIV int sr_new_virtual_device(const char *filename, struct sr_dev_inst **out sdi->dev_type = DEV_TYPE_FILELOG; get_file_short_name(filename, short_name, sizeof(short_name) - 1); - strncpy(sdi->name, (char*)short_name, sizeof(short_name) - 1); + sdi->name = g_strdup((const char*)short_name); sdi->path = g_strdup(filename); *out_di = sdi;