Unverified Commit d2e91778 authored by Ben Noordhuis's avatar Ben Noordhuis Committed by Anna Henningsen
Browse files

src: fix -Wmaybe-uninitialized compiler warning

Turn the `strategy_` method pointer into an enum-based static dispatch.

It's both safer and more secure (no chance of method pointer corruption)
and it helps GCC see that the shift and suffix tables it's complaining
about are unused in single char search mode.

Fixes the following warning:

    ../src/string_search.h:113:30: warning:
    ‘search’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         return (this->*strategy_)(subject, index);

Fixes: https://github.com/nodejs/node/issues/26733
Refs: https://github.com/nodejs/node/pull/31532
Refs: https://github.com/nodejs/node/pull/31798
PR-URL: https://github.com/nodejs/node/pull/31809


Reviewed-By: default avatarMichaël Zasso <targos@protonmail.com>
Reviewed-By: default avatarAnna Henningsen <anna@addaleax.net>
Reviewed-By: default avatarColin Ihrig <cjihrig@gmail.com>
Reviewed-By: default avatarRichard Lau <riclau@uk.ibm.com>
Reviewed-By: default avatarDenys Otrishko <shishugi@gmail.com>
Reviewed-By: default avatarDavid Carlier <devnexen@gmail.com>
Reviewed-By: default avatarSam Roberts <vieuxtech@gmail.com>
Reviewed-By: default avatarRuben Bridgewater <ruben@bridgewater.de>
Reviewed-By: default avatarJames M Snell <jasnell@gmail.com>
parent da6c7ba2
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment