Menu

#500 BOlePicture::Invoke fails to evaluate correctly wFlags

8
open
BOCOLE (2)
1
2022-12-29
2021-06-25
No

In the original source code of BOCOLE there is a bug that remains to the current OWLNext version of BOCOLE. In the source "bolepict.cpp (sourceforge.net)", in function member BOlePicture::Invoke:

  if ( !(wFlags & DISPATCH_PROPERTYGET|DISPATCH_PROPERTYPUT))
    return ResultFromScode(E_INVALIDARG);

This will evaluate first wFlags & DISPATCH_PROPERTYGET and the result will be logically or'ed with DISPATCH_PROPERTYPUT (which has the value 0x4, see "...\include\windows\rtl\sysvari.h"). So this sub-expression will always be true (and later will be logically negated).

The correct expression is:

  if ( !(wFlags & (DISPATCH_PROPERTYGET|DISPATCH_PROPERTYPUT)))
    return ResultFromScode(E_INVALIDARG);

Further info: https://docs.microsoft.com/en-us/cpp/c-language/precedence-and-order-of-evaluation?view=msvc-160

Related

Bugs: #501
Feature Requests: #184
Wiki: OWLNext_Roadmap_and_Prereleases

Discussion

  • Vidar Hasfjord

    Vidar Hasfjord - 2021-06-25

    Good catch!

     
  • Vidar Hasfjord

    Vidar Hasfjord - 2021-06-25
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,15 +1,14 @@
    -In the original source code of BOCOLE there its a bug that remain to current OWLNEXT version of BOCOLE. In the source bolepict.cpp, at function member  BOlePicture::Invoke:
    +In the original source code of BOCOLE there is a bug that remains to the current OWLNext version of BOCOLE. In the source "[bolepict.cpp](https://sourceforge.net/p/owlnext/code/5530/tree/trunk/source/ocf/BOCOLE/bolepict.cpp#l341)", in function member BOlePicture::Invoke:
    
     ~~~cpp
       if ( !(wFlags & DISPATCH_PROPERTYGET|DISPATCH_PROPERTYPUT))
         return ResultFromScode(E_INVALIDARG);
     ~~~
    
    -Will evaluate first: wFlags & DISPATCH_PROPERTYGET
    -and the result  wil 'ored' the with DISPATCH_PROPERTYPUT  (0x4. see ...\include\windows\rtl\sysvari.h)
    -So this sub-expression always will be true  (and later will be logically negated).
    +This will evaluate first `wFlags & DISPATCH_PROPERTYGET` and the result  will be logically or'ed with DISPATCH_PROPERTYPUT  (which has the value 0x4, see "...\\include\windows\\rtl\\sysvari.h"). So this sub-expression will always be true (and later will be logically negated).
    
     The correct expression is:
    +
     ~~~cpp
       if ( !(wFlags & (DISPATCH_PROPERTYGET|DISPATCH_PROPERTYPUT)))
         return ResultFromScode(E_INVALIDARG);
    

    Added link to the source code.

     

    Last edit: Vidar Hasfjord 2021-06-25
  • Vidar Hasfjord

    Vidar Hasfjord - 2021-06-26

    This issue was fixed in [r5531] on the 6.44 branch.

    TODO: This fix should be merged to the trunk and to the 7.0 branch, as well. Then post a comment here, documenting the completion of the fix, and set the ticket status to "pending" for review and release.

     

    Related

    Commit: [r5531]

  • Vidar Hasfjord

    Vidar Hasfjord - 2021-09-09

    This fix has now been merged to the trunk in [r5581] and temporarily undone on the 6.44 branch [r5584]. When the current work on BOCOLE is complete, the fix should be merged to the relevant supported release branches (currently 6.44 and 7.0), and this ticket status should be set to "pending" for review and release.

     

    Related

    Commit: [r5581]
    Commit: [r5584]

  • Vidar Hasfjord

    Vidar Hasfjord - 2022-02-05
    • Group: 6.44 --> 7.1
     

Log in to post a comment.

MongoDB Logo MongoDB