there is a bug in this procedure, the last byte of the binary C-string is not set to zero, causing the procedure to return random length string. On some systems it might work OK, on others it might crash.
The fix is to change few last lines to enforce zero at the last byte:
change the line:
output = mxCalloc(32, sizeof(char));
output = mxCalloc(33, sizeof(char));
/* call the C subroutine */
output=(char)0; // FIX HERE
plhs = mxCreateString(output);