mirror of
https://github.com/MariaDB/server.git
synced 2025-01-15 19:42:28 +01:00
Bug #7390 perror.exe doesn't work
perror.c: Copy output of strerr to temp buffer to prevent system overwrite on Windows extra/perror.c: Copy output of strerr to temp buffer to prevent system overwrite on Windows
This commit is contained in:
parent
4b88e07159
commit
199375cbc9
1 changed files with 12 additions and 1 deletions
|
@ -184,6 +184,7 @@ int main(int argc,char *argv[])
|
|||
{
|
||||
int error,code,found;
|
||||
const char *msg;
|
||||
char *unknown_error = 0;
|
||||
MY_INIT(argv[0]);
|
||||
|
||||
if (get_options(&argc,&argv))
|
||||
|
@ -212,7 +213,12 @@ int main(int argc,char *argv[])
|
|||
string 'Unknown Error'. To avoid printing it we try to find the
|
||||
error string by asking for an impossible big error message.
|
||||
*/
|
||||
const char *unknown_error= strerror(10000);
|
||||
msg = strerror(10000);
|
||||
|
||||
/* allocate a buffer for unknown_error since strerror always returns the same pointer
|
||||
on some platforms such as Windows */
|
||||
unknown_error = malloc( strlen(msg)+1 );
|
||||
strcpy( unknown_error, msg );
|
||||
|
||||
for ( ; argc-- > 0 ; argv++)
|
||||
{
|
||||
|
@ -262,6 +268,11 @@ int main(int argc,char *argv[])
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* if we allocated a buffer for unknown_error, free it now */
|
||||
if (unknown_error)
|
||||
free(unknown_error);
|
||||
|
||||
exit(error);
|
||||
return error;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue