So here I believe I have a small buffer overflow problem I found when reviewing someone else\'s code. It immediately struck me as incorrect, and potentially dangerous, but a
Your real problem is that you're writing
char* buffer = new char[strlen("This string is 27 char long" + 1)];
instead of
char* buffer = new char[strlen("This string is 27 char long") + 1];
Meaning that on the first one you're giving strlen() an address which isn't the beginning of your string.
Try this code:
const char szText[] = "This string is 27 char long";
char* buffer = new char[strlen(szText) + 1];
sprintf(buffer, szText);