Using a naked char[] here isn't necessary as QByteArray has a nice API for all of this. Calling constData() will also always return a 0-terminated string so no further handling is required. And then the whole manual memory handling can go away as QByteArray will care for this when it goes out of scope. Signed-off-by: Rolf Eike Beer <eb@xxxxxxxxx> --- scripts/kconfig/qconf.cc | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index e260cab1c2af..742ca6ed289b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1165,25 +1165,17 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char void ConfigInfoView::clicked(const QUrl &url) { QByteArray str = url.toEncoded(); - const std::size_t count = str.size(); - char *data = new char[count + 2]; // '$' + '\0' struct symbol **result; struct menu *m = NULL; - if (count < 1) { - delete[] data; + if (str.isEmpty()) return; - } - - memcpy(data, str.constData(), count); - data[count] = '\0'; /* Seek for exact match */ - data[0] = '^'; - strcat(data, "$"); - result = sym_re_search(data); + str[0] = '^'; + str.append('$'); + result = sym_re_search(str.constData()); if (!result) { - delete[] data; return; } @@ -1206,7 +1198,6 @@ void ConfigInfoView::clicked(const QUrl &url) } free(result); - delete[] data; } void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event) -- 2.47.0 -- Rolf Eike Beer emlix GmbH Headquarters: Berliner Str. 12, 37073 Göttingen, Germany Phone +49 (0)551 30664-0, e-mail info@xxxxxxxxx District Court of Göttingen, Registry Number HR B 3160 Managing Directors: Heike Jordan, Dr. Uwe Kracke VAT ID No. DE 205 198 055 Office Berlin: Panoramastr. 1, 10178 Berlin, Germany Office Bonn: Bachstr. 6, 53115 Bonn, Germany http://www.emlix.com emlix - your embedded Linux partner