[PATCH] covoar: Fix NULL check of wrong variable

Joel Sherrill joel at rtems.org
Wed Apr 7 15:50:33 UTC 2021


Repeating what I added to the ticket:

CID #1399602 is about a NULL reference in the same method which traces
 back to the incorrect variable being checked. Coverity didn't realize it
 was the wrong variable but did find something wrong that could lead to a
 NULL pointer dereference.

 Check me and please cite it in the ticket and git commit message.

On Wed, Apr 7, 2021 at 10:37 AM Alex White <alex.white at oarcorp.com> wrote:

> In Explanations::writeNotFound() there were two NULL checks of the
> `fileName` variable where only one is needed. The second check has been
> changed to a NULL check of `notFoundFile` to match the original intent.
>
> Closes #4377
> ---
>  tester/covoar/Explanations.cc | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tester/covoar/Explanations.cc b/tester/covoar/Explanations.cc
> index 7b0f95a..12bd809 100644
> --- a/tester/covoar/Explanations.cc
> +++ b/tester/covoar/Explanations.cc
> @@ -140,10 +140,10 @@ done:
>        return;
>
>      notFoundFile = fopen( fileName, "w" );
> -    if (!fileName) {
> +    if (notFoundFile == nullptr) {
>        std::ostringstream what;
>        what << "Unable to open " << fileName
> -           << "out of sync at the explanation";
> +           << " out of sync at the explanation";
>        throw rld::error( what, "Explanations::writeNotFound" );
>      }
>
> --
> 2.27.0
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210407/fc433330/attachment.html>


More information about the devel mailing list