Warning in CAxHost_IServiceProvider.inc

Started by Paul Squires, November 10, 2018, 04:52:44 PM

Previous topic - Next topic

Paul Squires

Hi Jose,

When compiling WinFBE 64 bit I get a warning. I preserved the generated C code and tracked down the warning to the CAxHost_IServiceProvider.inc file. Specifically, to the function below.


' ========================================================================================
' Acts as the factory method for any services exposed through an implementation of
' IServiceProvider.
' ========================================================================================
FUNCTION CAxHost_IServiceProvider.QueryService (BYVAL guidService AS const GUID const PTR, BYVAL riid AS const IID const PTR, BYVAL ppvObject AS ANY PTR PTR) AS HRESULT
   DIM pwsz AS WSTRING PTR
   StringFromIID(guidService, CAST(LPOLESTR PTR, @pwsz))
   DIM s AS STRING : IF pwsz THEN s = *pwsz : CoTaskMemFree(pwsz)
   StringFromIID(riid, CAST(LPOLESTR PTR, @pwsz))
   DIM s2 AS STRING : IF pwsz THEN s2 = *pwsz : CoTaskMemFree(pwsz)
'   CAXH_DP("CAxHost_IServiceProvider QueryService SID = " & s & " - IID = " & s2)
   CAXH_DP("QueryService SID = " & s)
   CAXH_DP("QueryService IID = " & s2)
   ' // Handle SID_SInPlaceBrowser (needed to enable the filesystem object to navigate
   ' // in-place within the WebBrowser control when running on Windows 7+)
   IF IsEqualIID(@guidService, @SID_SInPlaceBrowser) THEN
      RETURN AfxAxHostQueryService(CAST(IUnknown PTR, m_pAxHost->m_pOcx), @SID_SShellBrowser, riid, @ppvObject)
   END IF
   RETURN E_NOINTERFACE
END FUNCTION


From the C code, the warning line appears to be this one:

   IF IsEqualIID(@guidService, @SID_SInPlaceBrowser) THEN

It appears that the parameters in this IsEqualIID macro are of different sizes and there is a potential of reading past allocated memory. I have attached a copy of the actual warning message. You might be in a better position to eliminate the warning or ensure that the warning is not harmful.
Paul Squires
PlanetSquires Software

José Roca

#1
I'm not getting any warning compiling one of my web browser examples.

IID is an alias for GUID and it is defined as type IID as GUID in guiddef.bi.

Maybe a problem with "const" of a recent build of the compiler?

Paul Squires

You may be right although I think that I haven't been using the very latest compilers with the Const changes. This is the command line I am using (only the -O 2 optimization is out of the ordinary).

fbc64 WinFBE.bas -x ..\WinFBE64.exe -O 2 WinFBE.rc -s gui

(Later: I removed the -O 2 and now it compiles without warning but the exe is 350K larger)
Paul Squires
PlanetSquires Software

José Roca

Even using -O 2, I don't get any error with my example. Which is the text of the warning?

Paul Squires

The text is in the attachment in the first post of this thread.
Paul Squires
PlanetSquires Software

José Roca

I will have to try with the source code of the editor (is it up to date in GitHub?). A priori, the warning does not make sense, since both are GUIs with a size of 16 bytes, and my web browser examples compile fine.

Paul Squires

Yes, the source is up to date. I wouldn't worry too much about it. I expect maybe the -O 2 optimization may be playing with the structures too much. It might even be a false warning from GCC.
Paul Squires
PlanetSquires Software

Paul Squires

Since I upgraded to the Nov 22, 2018 Nightly Build, this error/warning has now disappeared.
Paul Squires
PlanetSquires Software

José Roca

That warning did not make sense, since IID is just an alias for GUID. Therefore, if both parameters are GUIDs, they can't be of different sizes.