
The source and destination strings for snprintf must not overlap. A simple check for the address of the source and destination should solve the case where they are the same. Behavior is undefined if the pointers aren't the same but the memory overlaps.