As already noted, you missed the space allocation for the trailing NUL character. But I also wanted to point out a few other things that can make your code more concise.
By definition, sizeof(char) always 1, so you can shorten your selection line to:
tempSides = (char*)malloc(strlen(inSides) + 1);
Another thing is that it looks like what you are doing to duplicate a row. There is a built-in function that does this for you:
tempSides = strdup(inSides);
This allows you to get the length by highlighting the correct number of bytes and copying the data.
R Samuel Klatchko
source share