cdbattags / lua-resty-jwt

JWT For The Great Openresty
Apache License 2.0
146 stars 44 forks source link

Correct the error handling when creating EVP ctx #22

Closed spacewander closed 4 years ago

spacewander commented 4 years ago
  1. should use xx == nil to check the returned NULL pointer
  2. there is no need to register GC finalizer twice
cdbattags commented 4 years ago

Any chance to add a unit test for this?

I'm good with the nil check but I'd love to find some unit-testable method to be absolutely certain GC isn't needed here.

spacewander commented 4 years ago

@cdbattags The GC handler is registered a few line below: https://github.com/cdbattags/lua-resty-jwt/blob/master/lib/resty/evp.lua#L246. So there is no need to register the same GC handler twice (the later one will replace the former one). We can only register the handler after the null check is passed.

cdbattags commented 4 years ago

@spacewander aha, didn't see that in the PR diff. Thanks for clarifying.

LGTM!

Thanks for your contribution!