Skip to content

Commit

Permalink
Fix memory leak caused by LLVMVerifyModule function call (TheDan64#507)
Browse files Browse the repository at this point in the history
Co-authored-by: Dan Kolsoi <[email protected]>
  • Loading branch information
antonbaliasnikov and TheDan64 authored Jul 27, 2024
1 parent d1c0936 commit c3f6e05
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use llvm_sys::core::{
LLVMDisposeModule, LLVMDumpModule, LLVMGetFirstFunction, LLVMGetFirstGlobal, LLVMGetLastFunction,
LLVMGetLastGlobal, LLVMGetModuleContext, LLVMGetModuleIdentifier, LLVMGetNamedFunction, LLVMGetNamedGlobal,
LLVMGetNamedMetadataNumOperands, LLVMGetNamedMetadataOperands, LLVMGetTarget, LLVMPrintModuleToFile,
LLVMPrintModuleToString, LLVMSetDataLayout, LLVMSetModuleIdentifier, LLVMSetTarget,
LLVMPrintModuleToString, LLVMSetDataLayout, LLVMSetModuleIdentifier, LLVMSetTarget, LLVMDisposeMessage
};
#[llvm_versions(7..)]
use llvm_sys::core::{LLVMAddModuleFlag, LLVMGetModuleFlag};
Expand Down Expand Up @@ -740,6 +740,8 @@ impl<'ctx> Module<'ctx> {
return unsafe { Err(LLVMString::new(err_str)) };
}

unsafe { LLVMDisposeMessage(err_str) };

Ok(())
}

Expand Down

0 comments on commit c3f6e05

Please sign in to comment.