I have created the following function to print out an error message. The message comes back into a character string pszMessage from a call to LSgetErrorMessage.
Code:
void printError(pLSenv pEnv, char* origin, int nErrorCode) {
char* pszMessage = "";
int nn = LSgetErrorMessage(pEnv, nErrorCode, pszMessage);
printf( "\nError from %s: %d - %s\n",origin,nErrorCode,pszMessage);
}
It is called called by the main program:
Code:
printError(env,"LScreateEnv",nErrorCode);
I am concerned that the string returned in pszMessage might be overwriting memory, but I'm not sure. Is the above code ok or will it stomp on memory. If so, how should it be modified to be safe?