diff --git a/src/pdb.ts b/src/pdb.ts index c5f8359..6bcddd4 100644 --- a/src/pdb.ts +++ b/src/pdb.ts @@ -33,7 +33,7 @@ export class PdbFile { } let fileHandle: FileHandle; - + let pdbFile: PdbFile; try { fileHandle = await open(pdbFilePath, 'r'); @@ -69,10 +69,12 @@ export class PdbFile { } const guid = new PdbGuid(guid_d1, guid_d2, guid_d3, guid_d4, age); - return new PdbFile(guid); + pdbFile = new PdbFile(guid); } finally { await fileHandle!?.close(); } + + return pdbFile; } private static async getGuidBytesFromPdbStream(root: PdbRootStream, fileHandle: FileHandle): Promise { diff --git a/src/pe.ts b/src/pe.ts index d35af12..74a5cfa 100644 --- a/src/pe.ts +++ b/src/pe.ts @@ -32,7 +32,7 @@ export class PeFile { } let fileHandle: FileHandle; - + let peFile: PeFile; try { fileHandle = await open(peFilePath, 'r'); @@ -62,9 +62,11 @@ export class PeFile { } const guid = new PeGuid(timeStamp, sizeOfImage); - return new PeFile(guid); + peFile = new PeFile(guid); } finally { await fileHandle!?.close(); } + + return peFile; } } diff --git a/src/root.ts b/src/root.ts index accf51c..5660565 100644 --- a/src/root.ts +++ b/src/root.ts @@ -50,7 +50,7 @@ export class PdbRootStream { return uints; } - static async createFromFile(filePath: string): Promise { + static async createFromFile(filePath: string): Promise { // LLVM.org refers to the first section of the file as The Superblock // At file offset 0 in an MSF file is the MSF SuperBlock, which is laid out as follows: // @@ -64,6 +64,7 @@ export class PdbRootStream { // ulittle32_t BlockMapAddr; // }; let fileHandle: FileHandle; + let pdbRootStream: PdbRootStream; try { const fileHandle = await open(filePath, 'r'); @@ -122,10 +123,12 @@ export class PdbRootStream { streamDirectory[i] = getStreamBytesAsNumber(rootPageData, i); } - return new PdbRootStream(blockSize, directoryBytesLength, streamDirectory); + pdbRootStream = new PdbRootStream(blockSize, directoryBytesLength, streamDirectory); } finally { fileHandle!?.close(); } + + return pdbRootStream; } }