Menu

#72 ecs_OpenDynamicLib fails on 64 bit Windows

None
closed
nobody
OGDI Core (13)
5
2016-07-11
2014-04-14
csd
No

The problem is in the ecs_OpenDynamicLib function (in ecs_dyna.c) within the #ifdef _WINDOWS block. The check for failed load looks like this:

if ((int) handle <= (int) HINSTANCE_ERROR) {
    // ... Handle LoadLibrary failure
}

On 64 bit Windows, LoadModule returns a 64 bit value, but int is 32 bit. Casting to (signed) int drops the high 32 bits. The low 32 bits, interpreted as an int can be negative, causing OGDI to think the load failed.

From reading the MSDN docs for LoadModule, it would seem that the correct check should be like this:

if (handle == NULL) {
    // ... Handle LoadLibrary failure
}

Discussion

  • Even Rouault

    Even Rouault - 2016-07-11

    Fixed in
    Checking in ogdi/c-api/ecs_dyna.c;
    /cvsroot/ogdi/devdir/ogdi/c-api/ecs_dyna.c,v <-- ecs_dyna.c
    new revision: 1.6; previous revision: 1.5

     
  • Even Rouault

    Even Rouault - 2016-07-11
    • status: open --> closed
    • Group: -->
     

Log in to post a comment.