chokkan / crfsuite

CRFsuite: a fast implementation of Conditional Random Fields (CRFs)
http://www.chokkan.org/software/crfsuite/
Other
641 stars 208 forks source link

fix: prevent from setting property level of null ptr #114

Closed franklevasseur closed 4 years ago

franklevasseur commented 4 years ago

The code is pretty much self explanatory!

returning variable crf1dt here prevent from line crf1dt->level = LEVEL_NONE; to be executed on a NULL ptr...

Error will be easier to debug for everybody using your lib. I had to debug for at least an hour with printf's to understand where the error came from... (I had no stack trace at all)

feel free to message me if you have any questions!

Good job for this library, it's really usefull.

François

cynthia commented 4 years ago

Apologies for the delay. I just looked at your patch, and yes - I can see the bug. Instead of having two duplicate returns, I think moving the level set call (line 165) inside the if block (between line 160 and 161) will simplify this patch while achieving the same effect.

If you have a testcase that lets me repro (I'm guessing this happened on a low memory environment) I'll try my version and see if the achieves the same effect.

chokkan commented 4 years ago

Thank you very much for sending this PR. I've just merged.