presence_dialoginfo: Fix bounds checking by using a helper function.

Reported by: dsandras
> About the bound checking error, the code was cut&pasted from another
> place in the same file where the same error is still present:
> ...

Also I replaced a heap str with a stack one in build_dialoginfo. This
one wasn't freed either unless an error condition was hit.
Merge pull request #177 from wdoekes/wjd-fix_dialogaggr_bounds

presence_dialoginfo: Fix bounds checking by using a helper function.