Re: [PATCH v2] http API: fix dangling pointer issue noted by GCC 12.0

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, Feb 25, 2022 at 10:09:11AM +0100, Ævar Arnfjörð Bjarmason wrote:
> There's a few possible ways to fix this, but the simplest is to assign
> NULL to "slot->finished" at the end of run_active_slot(), it's the
> only caller that ever assigns non-NULL to it. It was suggested[2] to
> guard that with "if (slot->finished == &finished)", but that'll still
> trigger the warning.

I'm not quite sure that I follow this. This isn't the only spot that
assigns non-NULL to "slot->finished", see the assignments in
http-walker.c:process_alternates_response() and
http.c:finish_active_slot().

But even if it were, I'm not sure how this being the only spot that
*writes* non-NULL matters from a reader's perspective.

Looking more at process_alternates_response(), it really looks like this
variable wants to hold a tri-state value. I wonder if it would be
clearer to replace the NULL/(pointer to) 0/(pointer to) 1 with a
UNKNOWN/TRUE/FALSE enum.

Thanks,
Taylor



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux