Skip to content

Commit

Permalink
kconfig: qconf: use delete[] instead of delete to free array
Browse files Browse the repository at this point in the history
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: c4f7398 ("kconfig: qconf: make debug links work again")
Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
  • Loading branch information
Masahiro Yamada committed Aug 1, 2020
1 parent 0e912c0 commit c9b09a9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions scripts/kconfig/qconf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1238,7 +1238,7 @@ void ConfigInfoView::clicked(const QUrl &url)

if (count < 1) {
qInfo() << "Clicked link is empty";
delete data;
delete[] data;
return;
}

Expand All @@ -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;
}

Expand Down

0 comments on commit c9b09a9

Please sign in to comment.