mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-24 12:03:02 +01:00
Protect from whatever possible (future) programming error that could cause a B.O. Probably the best fix is to make the constructor private and force all usage through the static raise() member function.
This commit is contained in:
parent
555894aab0
commit
2ab384e4d7
@ -24,7 +24,7 @@
|
|||||||
* Contributor(s): ______________________________________.
|
* Contributor(s): ______________________________________.
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* $Id: nbackup.cpp,v 1.37 2004-11-04 19:08:45 skidder Exp $
|
* $Id: nbackup.cpp,v 1.38 2004-11-10 04:25:51 robocop Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -98,13 +98,16 @@ class b_error : public std::exception
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit b_error(const char* message) {
|
explicit b_error(const char* message) {
|
||||||
strcpy(txt, message);
|
size_t len = sizeof(txt) - 1;
|
||||||
|
strncpy(txt, message, len);
|
||||||
|
txt[len] = 0;
|
||||||
}
|
}
|
||||||
|
enum {MSG_LEN = 1024};
|
||||||
virtual ~b_error() throw() {}
|
virtual ~b_error() throw() {}
|
||||||
virtual const char* what() const throw()
|
virtual const char* what() const throw()
|
||||||
{ return txt; }
|
{ return txt; }
|
||||||
static void raise(const char* message, ...) {
|
static void raise(const char* message, ...) {
|
||||||
char temp[1024];
|
char temp[MSG_LEN];
|
||||||
va_list params;
|
va_list params;
|
||||||
va_start(params, message);
|
va_start(params, message);
|
||||||
VSNPRINTF(temp, sizeof(temp), message, params);
|
VSNPRINTF(temp, sizeof(temp), message, params);
|
||||||
@ -114,7 +117,7 @@ public:
|
|||||||
throw b_error(temp);
|
throw b_error(temp);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
char txt[1024];
|
char txt[MSG_LEN];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -915,7 +918,7 @@ int main( int argc, char *argv[] )
|
|||||||
// Do not constify. GCC 3.4.0 chokes on minus below in this case
|
// Do not constify. GCC 3.4.0 chokes on minus below in this case
|
||||||
char **end = argv + argc, **argp;
|
char **end = argv + argc, **argp;
|
||||||
|
|
||||||
char *username = NULL, *password = NULL;
|
const char *username = NULL, *password = NULL;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Read global command line parameters
|
// Read global command line parameters
|
||||||
|
Loading…
Reference in New Issue
Block a user