Use lowercase filename to support compilation on Linux using MinGW.
Fixed potential resource leak of library handle (found by Coverity, CID 989315)
Fixed potential memory leak if "realloc" fails.
Removed logically dead code (found by Coverity, CID 989316).
Reserve and commit memory in one step (fixes error found by Coverity, CID 989314).