kopia lustrzana https://gitlab.com/sane-project/backends
Second try to fix problem with null-pointer in sane_control_option
rodzic
5bd47cafa7
commit
3b43770843
|
@ -3910,7 +3910,7 @@ sanei_hp_optset_control (HpOptSet this, HpData data,
|
||||||
hp_bool_t immediate)
|
hp_bool_t immediate)
|
||||||
{
|
{
|
||||||
HpOption opt = hp_optset_getByIndex(this, optnum);
|
HpOption opt = hp_optset_getByIndex(this, optnum);
|
||||||
SANE_Int my_info = 0;
|
SANE_Int my_info = 0, my_val = 0;
|
||||||
|
|
||||||
DBG(3,"sanei_hp_optset_control: %s\n", opt ? opt->descriptor->name : "");
|
DBG(3,"sanei_hp_optset_control: %s\n", opt ? opt->descriptor->name : "");
|
||||||
|
|
||||||
|
@ -3922,6 +3922,23 @@ sanei_hp_optset_control (HpOptSet this, HpData data,
|
||||||
if (!opt)
|
if (!opt)
|
||||||
return SANE_STATUS_INVAL;
|
return SANE_STATUS_INVAL;
|
||||||
|
|
||||||
|
/* There are problems with SANE_ACTION_GET_VALUE and valp == 0. */
|
||||||
|
/* Check if we really need valp. */
|
||||||
|
if ((action == SANE_ACTION_GET_VALUE) && (!valp))
|
||||||
|
{
|
||||||
|
/* Options without a value ? */
|
||||||
|
if ( (opt->descriptor->type == SANE_TYPE_BUTTON)
|
||||||
|
|| (opt->descriptor->type == SANE_TYPE_GROUP))
|
||||||
|
{
|
||||||
|
valp = &my_val; /* Just simulate a return value locally. */
|
||||||
|
}
|
||||||
|
else /* Others must return a value. So this is invalid */
|
||||||
|
{
|
||||||
|
DBG(1, "sanei_hp_optset_control: get value, but valp == 0\n");
|
||||||
|
return SANE_STATUS_INVAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (immediate)
|
if (immediate)
|
||||||
RETURN_IF_FAIL( hp_option_imm_control(this, opt, data, action, valp, infop,
|
RETURN_IF_FAIL( hp_option_imm_control(this, opt, data, action, valp, infop,
|
||||||
scsi) );
|
scsi) );
|
||||||
|
|
23
backend/hp.c
23
backend/hp.c
|
@ -883,29 +883,6 @@ sane_control_option (SANE_Handle handle, SANE_Int optnum,
|
||||||
|
|
||||||
DBG(10, "sane_control_option called\n");
|
DBG(10, "sane_control_option called\n");
|
||||||
|
|
||||||
status = SANE_STATUS_GOOD;
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case SANE_ACTION_GET_VALUE:
|
|
||||||
case SANE_ACTION_SET_VALUE:
|
|
||||||
if (!valp)
|
|
||||||
{
|
|
||||||
DBG (1,"sane_control_option: valp is NULL\n");
|
|
||||||
status = SANE_STATUS_INVAL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SANE_ACTION_SET_AUTO:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
DBG (1,"sane_control_option: action unknown\n");
|
|
||||||
status = SANE_STATUS_INVAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != SANE_STATUS_GOOD) return status;
|
|
||||||
|
|
||||||
status = sanei_hp_handle_control(h, optnum, action, valp, info);
|
status = sanei_hp_handle_control(h, optnum, action, valp, info);
|
||||||
|
|
||||||
DBG(10, "sane_control_option will finish with %s\n",
|
DBG(10, "sane_control_option will finish with %s\n",
|
||||||
|
|
Ładowanie…
Reference in New Issue