diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2014-04-15 07:25:22 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2014-04-23 10:04:29 -0700 |
| commit | de7845ac72e01b491b4ed352f23c2c9a73efc45b (patch) | |
| tree | 1b834db9811246cc36ac73f64a0584ac07702019 /src/rustllvm/PassWrapper.cpp | |
| parent | bb580f1a56138bd5a96ccc95c0f61caab72cf975 (diff) | |
| download | rust-de7845ac72e01b491b4ed352f23c2c9a73efc45b.tar.gz rust-de7845ac72e01b491b4ed352f23c2c9a73efc45b.zip | |
rustc: Fix passing errors from LLVM to rustc
Many of the instances of setting a global error variable ended up leaving a dangling pointer into free'd memory. This changes the method of error transmission to strdup any error and "relinquish ownership" to rustc when it gets an error. The corresponding Rust code will then free the error as necessary. Closes #12865
Diffstat (limited to 'src/rustllvm/PassWrapper.cpp')
| -rw-r--r-- | src/rustllvm/PassWrapper.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp index 32bac73debf..021dda49765 100644 --- a/src/rustllvm/PassWrapper.cpp +++ b/src/rustllvm/PassWrapper.cpp @@ -75,7 +75,7 @@ LLVMRustCreateTargetMachine(const char *triple, const llvm::Target *TheTarget = TargetRegistry::lookupTarget(Trip.getTriple(), Error); if (TheTarget == NULL) { - LLVMRustError = Error.c_str(); + LLVMRustSetLastError(Error.c_str()); return NULL; } @@ -178,7 +178,7 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target, raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary); #endif if (ErrorInfo != "") { - LLVMRustError = ErrorInfo.c_str(); + LLVMRustSetLastError(ErrorInfo.c_str()); return false; } formatted_raw_ostream FOS(OS); |
