- hres = to_int(arg, &val);
- V_VT(&v) = VT_EMPTY;
- hres = VariantChangeType(&v, arg, 0, VT_I2); if(FAILED(hres)) return hres;
- return return_int(res, val);
- if(!res) {
VariantClear(&v);
return DISP_E_BADVARTYPE;
- }
- *res = v;
- return S_OK;
I can't comment on removing to_int() here, I don't know this code well. But is it really possible to get a NULL 'res'? It looks like you can just use 'res' without intermediate 'v'. In any case you don't need VariantClear() on VT_I2 variant.