[haiku-commits] Re: haiku: hrev46275 - src/add-ons/kernel/bus_managers/pci/arch/x86

  • From: Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 22 Oct 2013 12:21:32 +0200 (CEST)

> On October 22, 2013 at 7:48 AM pulkomandy <pulkomandy@xxxxxxxxxxxxx> wrote:
> > -             if (rsdt != NULL
> > -                     && strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) !=
> > 0) {
> > +             if (rsdt == NULL) {
> > +                     TRACE(("acpi: couldn't map rsdt header\n"));
> > +                     return B_ERROR;
> > +             }
> > +             if (strncmp(rsdt->signature, ACPI_RSDT_SIGNATURE, 4) != 0) {
> As far as I know, the && operator in C is sort-circuit, so if rsdt is
> NULL, the second part of the condition isn't tested. Am I wrong ?

It's amazing (and a bit frightening :-)) that you aren't completely sure of
this, but of course you are right.
It's just that the null pointer dereference is not part of the diff -- the
"return B_ERROR;" does all the magic here :-)

Bye,
   Axel.

Other related posts: