diff options
author | Peter Wu <peter@lekensteyn.nl> | 2018-05-04 22:21:13 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2018-05-09 18:41:37 +0000 |
commit | 5507a34d1f0d1f96b3dc5283cca0619b05853f89 (patch) | |
tree | 72c6ef7939ae033e6f9df66227ba4fb5ec8330f3 /ui/qt | |
parent | 064c09a293ea044baa4a06eb682b2e8e046fe0e2 (diff) |
Qt: fix memleaks in CompiledFilterOutput
QString already copies the memory, no need to strdup it. Simplify use of
GString as well (str is NUL terminated). Found by Clang Static Analyzer.
Change-Id: Ic3ba3daa9121736529e0bee2d41adc95a55a3feb
Fixes: v1.99.0-rc1-253-gdf8c4bf264 ("Capture Interfaces Dialog:")
Reviewed-on: https://code.wireshark.org/review/27344
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Diffstat (limited to 'ui/qt')
-rw-r--r-- | ui/qt/compiled_filter_output.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/ui/qt/compiled_filter_output.cpp b/ui/qt/compiled_filter_output.cpp index 8a268c3599..1f0f6b2c75 100644 --- a/ui/qt/compiled_filter_output.cpp +++ b/ui/qt/compiled_filter_output.cpp @@ -78,21 +78,20 @@ void CompiledFilterOutput::compileFilter() break; g_mutex_lock(pcap_compile_mtx); if (pcap_compile(pd, &fcode, compile_filter_.toUtf8().constData(), 1, 0) < 0) { - compile_results.insert(interfaces, QString("%1").arg(g_strdup(pcap_geterr(pd)))); + compile_results.insert(interfaces, QString(pcap_geterr(pd))); g_mutex_unlock(pcap_compile_mtx); ui->interfaceList->addItem(new QListWidgetItem(QIcon(":expert/expert_error.png"),interfaces)); } else { GString *bpf_code_dump = g_string_new(""); struct bpf_insn *insn = fcode.bf_insns; int ii, n = fcode.bf_len; - gchar *bpf_code_str; for (ii = 0; ii < n; ++insn, ++ii) { g_string_append(bpf_code_dump, bpf_image(insn, ii)); g_string_append(bpf_code_dump, "\n"); } - bpf_code_str = g_string_free(bpf_code_dump, FALSE); g_mutex_unlock(pcap_compile_mtx); - compile_results.insert(interfaces, QString("%1").arg(g_strdup(bpf_code_str))); + compile_results.insert(interfaces, QString(bpf_code_dump->str)); + g_string_free(bpf_code_dump, TRUE); ui->interfaceList->addItem(new QListWidgetItem(interfaces)); } break; |