From a716beeef8abf4e2b7dc0188bef78a060f8ea924 Mon Sep 17 00:00:00 2001 From: dreamsource-tai Date: Thu, 25 Jul 2024 11:29:22 +0800 Subject: [PATCH] fix: Have not free the char buffer formatting from base lib --- DSView/pv/prop/binding/deviceoptions.cpp | 13 +++++++++---- DSView/pv/prop/binding/probeoptions.cpp | 6 +++++- DSView/pv/storesession.cpp | 3 ++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/DSView/pv/prop/binding/deviceoptions.cpp b/DSView/pv/prop/binding/deviceoptions.cpp index 4fe6b22e..64356602 100644 --- a/DSView/pv/prop/binding/deviceoptions.cpp +++ b/DSView/pv/prop/binding/deviceoptions.cpp @@ -260,8 +260,7 @@ void DeviceOptions::bind_samplerate(const QString &name, const QString label, QString DeviceOptions::print_samplerate(GVariant *const gvar) { - char *const s = sr_samplerate_string( - g_variant_get_uint64(gvar)); + char *const s = sr_samplerate_string(g_variant_get_uint64(gvar)); const QString qstring(s); g_free(s); return qstring; @@ -293,14 +292,20 @@ QString DeviceOptions::print_timebase(GVariant *const gvar) { uint64_t p, q; g_variant_get(gvar, "(tt)", &p, &q); - return QString(sr_period_string(p * q)); + char *pstr = sr_period_string(p * q); + QString qstr(pstr); + g_free(pstr); + return qstr; } QString DeviceOptions::print_vdiv(GVariant *const gvar) { uint64_t p, q; g_variant_get(gvar, "(tt)", &p, &q); - return QString(sr_voltage_string(p, q)); + char *pstr = sr_voltage_string(p, q); + QString qstr(pstr); + g_free(pstr); + return qstr; } void DeviceOptions::bind_bandwidths(const QString &name, const QString label, int key, diff --git a/DSView/pv/prop/binding/probeoptions.cpp b/DSView/pv/prop/binding/probeoptions.cpp index bfd2381a..3d9ac3ef 100644 --- a/DSView/pv/prop/binding/probeoptions.cpp +++ b/DSView/pv/prop/binding/probeoptions.cpp @@ -222,7 +222,11 @@ QString ProbeOptions::print_vdiv(GVariant *const gvar) q = 1; p /= 1000; } - return QString(sr_voltage_string(p, q)); + + char *pstr = sr_voltage_string(p, q); + QString qstr(pstr); + g_free(pstr); + return qstr; } QString ProbeOptions::print_coupling(GVariant *const gvar) diff --git a/DSView/pv/storesession.cpp b/DSView/pv/storesession.cpp index 4edfb234..f7cfe38e 100644 --- a/DSView/pv/storesession.cpp +++ b/DSView/pv/storesession.cpp @@ -618,8 +618,9 @@ bool StoreSession::meta_gen(data::Snapshot *snapshot, std::string &str) } s = sr_samplerate_string(_session->cur_snap_samplerate()); - sprintf(meta, "samplerate = %s\n", s); str += meta; + g_free(s); + s = NULL; uint64_t tmp_u64; int tmp_u8;