Commit 2c5aae46 authored by unknown's avatar unknown

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)
parent 53a0e299
......@@ -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 */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment