[systemd-devel] [PATCH 2/2] sysv-generator: remove NULL pointer dereference

Shawn Landden shawn at churchofgit.com
Sun Apr 26 15:00:05 PDT 2015


 static void free_sysvstub_hashmapp(Hashmap **h) {
         while ((stub = hashmap_steal_first(*h)))

_cleanup_ sends a pointer to the pointer. and then this dereferences
that, which is kinda confusing, but yeah the code is correct, it would
be clearer with DEFINE_TRIVIAL_CLEANUP_FUNC()

On Sun, Apr 26, 2015 at 12:04 PM, Thomas H.P. Andersen <phomes at gmail.com> wrote:
> On Sun, Apr 26, 2015 at 8:31 PM, Thomas H.P. Andersen <phomes at gmail.com> wrote:
>> On Sun, Apr 26, 2015 at 8:23 PM, Shawn Landden <shawn at churchofgit.com> wrote:
>>> Actually you missed that free_sysvstub_hashmap does not tolerate NULL pointers.
>> Indeed. I will commit that.
>
> Wait. free_sysvstub_hashmapp does tolerate NULL pointers.
>
> hashmap_steal_first will return NULL if the hashmap is NULL. And
> hashmap_free is fine with NULL too. Your patch makes it more obvious
> that free_sysvstub_hashmapp does tolerate NULL but destructors should
> tolerate NULL as per the coding style. So I guess it should just be
> assumed? I will leave it up to the others to decide what the best
> style is here.
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel



-- 
Shawn Landden


More information about the systemd-devel mailing list