snudown icon indicating copy to clipboard operation
snudown copied to clipboard

Initialize struct with the correct number of members

Open erikdesjardins opened this issue 6 years ago • 4 comments

b5ade1a697b48c7893fbbbde3d708ed9bb111f29 (#78) added two members to this struct, but only one to this initializer. This leads to undefined behaviour when rendering something like #/u/test, since the other callback functions are called through wrongly-typed function pointers.

(It's my understanding that reddit doesn't use Snudown to render the ToC, and hence doesn't test this code path, but I'm surprised that compiler warnings about this were disabled [or ignored?])

erikdesjardins avatar Mar 11 '18 19:03 erikdesjardins

Hi @erikdesjardins. Thanks for this patch. I'll ping someone who can review.

brson avatar Mar 29 '18 18:03 brson

@erikdesjardins are you depending on this code path, or just submitting this as cleanup?

brson avatar Mar 29 '18 18:03 brson

I do use this, but I already use a fork (where it's compiled to JS/wasm) so I don't depend on it being upstreamed.

erikdesjardins avatar Mar 29 '18 22:03 erikdesjardins

Yeah, we don't use the ToC renderer, but I don't recall seeing any warnings about it when I last looked. Might be a clang / GCC thing, or maybe it'd changed since then? Def a bug though. @birakattack ^

JordanMilne avatar Mar 29 '18 22:03 JordanMilne