diff options
author | unknown <jani@rhols221.adsl.netsonic.fi> | 2002-10-15 22:10:15 +0300 |
---|---|---|
committer | unknown <jani@rhols221.adsl.netsonic.fi> | 2002-10-15 22:10:15 +0300 |
commit | 2c5aae462a4038f0e3d7dc200128f5d876c59a13 (patch) | |
tree | aefa0b750123f8a080d90baf2ae2b5429a00e8ec /mysys/my_getopt.c | |
parent | 53a0e2992a08a08a03ffad32e6d65ee18d9505b0 (diff) | |
download | mariadb-git-2c5aae462a4038f0e3d7dc200128f5d876c59a13.tar.gz |
Fixed a bug in my_getopt
mysys/my_getopt.c:
Fixed a bug in my_getopt; using NULL or 0 as u_max_value caused segmentation
fault even in those programs that didn't have any use for this feature
(prefix --maximum)
Diffstat (limited to 'mysys/my_getopt.c')
-rw-r--r-- | mysys/my_getopt.c | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 494e7ac559c..b2ee6e0f373 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -634,31 +634,38 @@ static void init_variables(const struct my_option *options) { switch (options->var_type) { case GET_BOOL: - *((my_bool*) options->u_max_value)= (my_bool) options->max_value; + if (options->u_max_value) + *((my_bool*) options->u_max_value)= (my_bool) options->max_value; *((my_bool*) options->value)= (my_bool) options->def_value; break; case GET_INT: - *((int*) options->u_max_value)= (int) options->max_value; + if (options->u_max_value) + *((int*) options->u_max_value)= (int) options->max_value; *((int*) options->value)= (int) options->def_value; break; case GET_UINT: - *((uint*) options->u_max_value)= (uint) options->max_value; + if (options->u_max_value) + *((uint*) options->u_max_value)= (uint) options->max_value; *((uint*) options->value)= (uint) options->def_value; break; case GET_LONG: - *((long*) options->u_max_value)= (long) options->max_value; + if (options->u_max_value) + *((long*) options->u_max_value)= (long) options->max_value; *((long*) options->value)= (long) options->def_value; break; case GET_ULONG: - *((ulong*) options->u_max_value)= (ulong) options->max_value; + if (options->u_max_value) + *((ulong*) options->u_max_value)= (ulong) options->max_value; *((ulong*) options->value)= (ulong) options->def_value; break; case GET_LL: - *((longlong*) options->u_max_value)= (longlong) options->max_value; + if (options->u_max_value) + *((longlong*) options->u_max_value)= (longlong) options->max_value; *((longlong*) options->value)= (longlong) options->def_value; break; case GET_ULL: - *((ulonglong*) options->u_max_value)= (ulonglong) options->max_value; + if (options->u_max_value) + *((ulonglong*) options->u_max_value)= (ulonglong) options->max_value; *((ulonglong*) options->value)= (ulonglong) options->def_value; break; default: /* dummy default to avoid compiler warnings */ |