Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FIXED] microService_AddEndpoint() could crash if subject is invalid (#…
…831) Saw that looking at the build log in GitHub actions: ``` /home/runner/work/nats.c/nats.c/src/micro.c: In function ‘micro_add_endpoint’: /home/runner/work/nats.c/nats.c/src/micro.c:153:16: warning: pointer used after ‘free’ [-Wuse-after-free] 153 | return microError_Wrapf(micro_ErrorInvalidArg, "invalid subject '%s' for endpoint '%s'", fullSubject, cfg->Name); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /home/runner/work/nats.c/nats.c/src/microp.h:18, from /home/runner/work/nats.c/nats.c/src/micro.c:16: /home/runner/work/nats.c/nats.c/src/mem.h:28:29: note: call to ‘free’ here 28 | #define NATS_FREE(p) free((p)) | ^~~~~~~~~ /home/runner/work/nats.c/nats.c/src/micro.c:152:9: note: in expansion of macro ‘NATS_FREE’ 152 | NATS_FREE(fullSubject); | ^~~~~~~~~ ``` Added an invalid subject endpoint config in one of the test to verify the issue and the fix. Signed-off-by: Ivan Kozlovic <[email protected]>
- Loading branch information