issue in ActiveXControlComponent::createControl

In the following part of the method, the info pointer is released at the beginning of the block, but it is used later and thus it results in accessing a null pointer.

I think the control = info.release() line should have been put immediately before the return statement

[code] if (info->control->DoVerb (OLEIVERB_SHOW, 0, info->clientSite, 0, hwnd, &rect) == S_OK)
{
control = info.release();
setControlBounds (Rectangle (x, y, getWidth(), getHeight()));

                info->controlHWND = getHWND (this);

                if (info->controlHWND != 0)
                {
                    originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) info->controlHWND, GWLP_WNDPROC);
                    SetWindowLongPtr ((HWND) info->controlHWND, GWLP_WNDPROC, (LONG_PTR) activeXHookWndProc);
                }

                return true;
            }

[/code]

Yes, sorry about that one. I had actually already spotted it, but haven’t had chance to do a check-in yet…

How would the code look like? I’d need to fix it ASAP

Moving the release() to be before the return like you suggested would work fine.

No it doesn’t because the setControlBounds function relies on having “control” already initialised, which is not the case if I move the line control = info.release() at the bottom

I meant move the release(), but not the "control = " bit… Anyway, here’s what I had:

[code] if (info->control->DoVerb (OLEIVERB_SHOW, 0, info->clientSite, 0, hwnd, &rect) == S_OK)
{
control = info.release();
setControlBounds (Rectangle (x, y, getWidth(), getHeight()));

                ((ActiveXControlData*) control)->controlHWND = getHWND (this);

                if (((ActiveXControlData*) control)->controlHWND != 0)
                {
                    originalWndProc = (void*) (pointer_sized_int) GetWindowLongPtr ((HWND) ((ActiveXControlData*) control)->controlHWND, GWLP_WNDPROC);
                    SetWindowLongPtr ((HWND) ((ActiveXControlData*) control)->controlHWND, GWLP_WNDPROC, (LONG_PTR) activeXHookWndProc);
                }

                return true;
            }

[/code]