]> git.baikalelectronics.ru Git - kernel.git/commitdiff
kconfig: qconf: use delete[] instead of delete to free array
authorMasahiro Yamada <masahiroy@kernel.org>
Wed, 29 Jul 2020 17:02:39 +0000 (02:02 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Sat, 1 Aug 2020 11:54:39 +0000 (20:54 +0900)
cppcheck reports "Mismatching allocation and deallocation".

$ cppcheck scripts/kconfig/qconf.cc
Checking scripts/kconfig/qconf.cc ...
scripts/kconfig/qconf.cc:1242:10: error: Mismatching allocation and deallocation: data [mismatchAllocDealloc]
  delete data;
         ^
scripts/kconfig/qconf.cc:1236:15: note: Mismatching allocation and deallocation: data
 char *data = new char[count + 1];
              ^
scripts/kconfig/qconf.cc:1242:10: note: Mismatching allocation and deallocation: data
  delete data;
         ^
scripts/kconfig/qconf.cc:1255:10: error: Mismatching allocation and deallocation: data [mismatchAllocDealloc]
  delete data;
         ^
scripts/kconfig/qconf.cc:1236:15: note: Mismatching allocation and deallocation: data
 char *data = new char[count + 1];
              ^
scripts/kconfig/qconf.cc:1255:10: note: Mismatching allocation and deallocation: data
  delete data;
         ^

Fixes: da3ebf8b1332 ("kconfig: qconf: make debug links work again")
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
scripts/kconfig/qconf.cc

index bb0a0bd511b9b9023248213d8c3be5e2c459a855..3a11940ff5dc0b84f9b6b66d67ef6d757aae5396 100644 (file)
@@ -1238,7 +1238,7 @@ void ConfigInfoView::clicked(const QUrl &url)
 
        if (count < 1) {
                qInfo() << "Clicked link is empty";
-               delete data;
+               delete[] data;
                return;
        }
 
@@ -1251,7 +1251,7 @@ void ConfigInfoView::clicked(const QUrl &url)
        result = sym_re_search(data);
        if (!result) {
                qInfo() << "Clicked symbol is invalid:" << data;
-               delete data;
+               delete[] data;
                return;
        }