diff options
author | reggie@bob.(none) <> | 2005-02-01 08:16:45 -0600 |
---|---|---|
committer | reggie@bob.(none) <> | 2005-02-01 08:16:45 -0600 |
commit | 3066e117b081851433be67e4481455dc9e6f130a (patch) | |
tree | 44d1790b3fbec9cc4d77f441ddbe26a42fe85188 | |
parent | 6c272a5a35d8e7d19576cd449afb3c2a24044d9f (diff) | |
parent | a5bd37e1459a0628e2897325f003abaca5937c6e (diff) | |
download | mariadb-git-3066e117b081851433be67e4481455dc9e6f130a.tar.gz |
Merge bob.(none):/home/reggie/bk/mysql41
into bob.(none):/home/reggie/bk/mysql5.0
-rw-r--r-- | extra/perror.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/extra/perror.c b/extra/perror.c index e667ea723b8..3e920ac50a4 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -189,6 +189,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)) @@ -217,7 +218,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++) { @@ -267,6 +273,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; } |