REP_TEXT_MUSTBEFREED looks like a bad idea, at lest for now:
Errors can happen anywhere, and then sr_text is usually set
to a string constant. If REP_TEXT_MUSTBEFREED is already set,
slapd will then later try to free that constant.
To add this flag, first add result.c:rs_replace_text() or
something similar, like rs_replace_entry(). Modify all code
which modifies sr_text to use this function/macro, and
encourage 3rd party code to do the same.
Also look at code which copies a SlapReply.
Each REP_*_MUSTBEFREED flag and its related data should be
managed by a similar function/macro, really.
(I tried to add a comment in Github, but that didn't
seem to work, so mailing here instead.)