Page MenuHomeFreeBSD

ctld: Consistently free temporary strings during yacc parsing
ClosedPublic

Authored by jhb on Tue, Feb 11, 1:20 AM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Feb 15, 5:00 AM
Unknown Object (File)
Wed, Feb 12, 8:21 PM
Unknown Object (File)
Tue, Feb 11, 1:51 AM
Subscribers

Details

Summary

The lexer always allocates a duplicate string via strdup for STR
tokens. The parse handlers did not always free these duplicated
strings after consuming them.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

jhb requested review of this revision.Tue, Feb 11, 1:20 AM

Did you check for any similar resource leaks in uclparse.c ?

This revision is now accepted and ready to land.Tue, Feb 11, 6:20 PM

Did you check for any similar resource leaks in uclparse.c ?

I did not, but AFAIK, the ucl_get_* routines don't return storage to the caller. They seem to be more like nvlist_get_* rather than nvlist_take_*. In particular, the uclparse.c code is already careful to strdup() any strings it wants to save in the configuration.

Note that after my changes later in this series, we always do the same for the yacc/lex parser as well, and we probably could remove the strdup() calls in token.l and all the free() calls in parse.y which would simplify things a bit.