diff mbox series

[1/2] kconfig: qconf: use delete[] instead of delete to free array (again)

Message ID 20200908221638.2782778-1-masahiroy@kernel.org
State New
Headers show
Series [1/2] kconfig: qconf: use delete[] instead of delete to free array (again) | expand

Commit Message

Masahiro Yamada Sept. 8, 2020, 10:16 p.m. UTC
Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete
to free array") fixed two lines, but there is one more.
(cppcheck does not report it for some reason...)

This was detected by Clang.

"make HOSTCXX=clang++ xconfig" reports the following:

scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
        delete data;
        ^
              []
scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here
        char *data = new char[count + 1];
                     ^

Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again")
Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/qconf.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Nick Desaulniers Sept. 10, 2020, 5:24 p.m. UTC | #1
On Tue, Sep 8, 2020 at 3:17 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete
> to free array") fixed two lines, but there is one more.
> (cppcheck does not report it for some reason...)
>
> This was detected by Clang.
>
> "make HOSTCXX=clang++ xconfig" reports the following:
>
> scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
>         delete data;
>         ^
>               []
> scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here
>         char *data = new char[count + 1];
>                      ^
>
> Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again")
> Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array")
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>
>  scripts/kconfig/qconf.cc | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> index 8638785328a7..c7216b9110fc 100644
> --- a/scripts/kconfig/qconf.cc
> +++ b/scripts/kconfig/qconf.cc
> @@ -1276,7 +1276,7 @@ void ConfigInfoView::clicked(const QUrl &url)
>         }
>
>         free(result);
> -       delete data;
> +       delete[] data;
>  }
>
>  void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
> --
> 2.25.1
>
Masahiro Yamada Sept. 17, 2020, 4:08 p.m. UTC | #2
On Fri, Sep 11, 2020 at 2:24 AM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> On Tue, Sep 8, 2020 at 3:17 PM Masahiro Yamada <masahiroy@kernel.org> wrote:
> >
> > Commit c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete
> > to free array") fixed two lines, but there is one more.
> > (cppcheck does not report it for some reason...)
> >
> > This was detected by Clang.
> >
> > "make HOSTCXX=clang++ xconfig" reports the following:
> >
> > scripts/kconfig/qconf.cc:1279:2: warning: 'delete' applied to a pointer that was allocated with 'new[]'; did you mean 'delete[]'? [-Wmismatched-new-delete]
> >         delete data;
> >         ^
> >               []
> > scripts/kconfig/qconf.cc:1239:15: note: allocated with 'new[]' here
> >         char *data = new char[count + 1];
> >                      ^
> >
> > Fixes: c4f7398bee9c ("kconfig: qconf: make debug links work again")
> > Fixes: c9b09a9249e6 ("kconfig: qconf: use delete[] instead of delete to free array")
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
>
> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
>
> > ---
> >
> >  scripts/kconfig/qconf.cc | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
> > index 8638785328a7..c7216b9110fc 100644
> > --- a/scripts/kconfig/qconf.cc
> > +++ b/scripts/kconfig/qconf.cc
> > @@ -1276,7 +1276,7 @@ void ConfigInfoView::clicked(const QUrl &url)
> >         }
> >
> >         free(result);
> > -       delete data;
> > +       delete[] data;
> >  }
> >
> >  void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)
> > --
> > 2.25.1
> >
>
>
> --
> Thanks,
> ~Nick Desaulniers
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/CAKwvOdnP7UmpRPL8XjzoMPjgQb9Di8OXk9UEX8NWaa35A01Q3Q%40mail.gmail.com.



Applied to linux-kbuild/fixes.
diff mbox series

Patch

diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index 8638785328a7..c7216b9110fc 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -1276,7 +1276,7 @@  void ConfigInfoView::clicked(const QUrl &url)
 	}
 
 	free(result);
-	delete data;
+	delete[] data;
 }
 
 void ConfigInfoView::contextMenuEvent(QContextMenuEvent *event)