Duplicate use of internal text in one string caused segfault

Version 1.46

Bugfix
Finished

recent code changes exposed an old InternalText class bug, where doing something like this: printf("%s %s\n", hc.t(75, "Domain Pointer on"), hc.t(75, "Domain Pointer on")); would cause a segfault, because the 2nd instance of the internal text usage deletes the first one, causing any use of the first %s to be unpredictable. Fix was to count the number of varables.. and if there are zero (eg: the above has zero %s characters), don't reset the array id 75.. since it's already there, and will never change anyway. I've also optimized it by doing (this is just an example optimization, not actually used as shown): char *str = hc.t(75, "Domain Pointer on"); printf("%s %s\n", str, str); as, in a loop, it would mean far fewer index look-ups on the InternalText arrays. It's also decided that using 2 calls of the same text ID in one call is bad practice, so I'll swap them out whenever found (not to mention not as efficient as they could be)

Interested to try DirectAdmin? Get a 30-day Free Trial!