8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 15:23:03 +01:00

Adriano says we shouldn't assume argv[argc] is null.

This commit is contained in:
robocop 2009-11-09 06:19:47 +00:00
parent 9f87c75553
commit b58ac3f91d

View File

@ -6951,10 +6951,9 @@ static processing_state parse_arg(int argc, SCHAR** argv, SCHAR* tabname)
switch_used[su] = false; switch_used[su] = false;
} }
int i = 1; for (int i = 1; i < argc; ++i)
const char* s = argv[i];
while (i < argc)
{ {
const char* s = argv[i];
// Look at flags to find unique match. If the flag has an arg, // Look at flags to find unique match. If the flag has an arg,
// advance the pointer (and i). Only change the return value // advance the pointer (and i). Only change the return value
// for extract switch or error. // for extract switch or error.
@ -6987,7 +6986,8 @@ static processing_state parse_arg(int argc, SCHAR** argv, SCHAR* tabname)
if (switches[j].argtype != SWARG_NONE) if (switches[j].argtype != SWARG_NONE)
{ {
// make sure swarg_str is really a pointer to argv, not something else !! // make sure swarg_str is really a pointer to argv, not something else !!
swarg_str = argv[++i]; if (++i < argc)
swarg_str = argv[i];
if (!swarg_str || !*swarg_str) if (!swarg_str || !*swarg_str)
{ {
ISQL_msg_get(USAGE_NOARG, errbuf, SafeArg() << (s + 1)); ISQL_msg_get(USAGE_NOARG, errbuf, SafeArg() << (s + 1));
@ -7247,7 +7247,7 @@ static processing_state parse_arg(int argc, SCHAR** argv, SCHAR* tabname)
fb_utils::copy_terminate(isqlGlob.global_Db_name, s, sizeof(isqlGlob.global_Db_name)); fb_utils::copy_terminate(isqlGlob.global_Db_name, s, sizeof(isqlGlob.global_Db_name));
#ifdef DEV_BUILD #ifdef DEV_BUILD
// If there is a table name, it follows // If there is a table name, it follows
if (istable && (s = argv[++i]) && *s) if (istable && (++i < argc) && (s = argv[i]) && *s)
fb_utils::copy_terminate(tabname, s, WORDLENGTH); fb_utils::copy_terminate(tabname, s, WORDLENGTH);
#endif #endif
} }
@ -7256,8 +7256,6 @@ static processing_state parse_arg(int argc, SCHAR** argv, SCHAR* tabname)
// Quit the loop of interpreting if we got an error // Quit the loop of interpreting if we got an error
if (ret == ps_ERR) if (ret == ps_ERR)
break; break;
s = argv[++i];
} }
// If not input, then set up first filelist // If not input, then set up first filelist