Implement yr_strndup
Fix possible buffer overrun
Remove references to "aprintf" and fix a memory leak

"aprintf" calls "malloc" internally, but the strings is freed by using "yr_free", this causes an imbalance in the number of calls to "yr_malloc" and "yr_free" breaking tools for detecting memory leaks. The other option would be using "free" for those specific strings, but maintaining coherence is preferred.