Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid NullReferenceExeption in GetTextFromQuery (#346)
In rare cases, a thread-scheduling race condition can cause a thread's state to be ThreadState.Stopped even though it hasn't yet executed its `finally` block, which can result in result.StandardOutput or Error not being assigned a string, leaving them null. Furthermore, the C# docs say not to depend on ThreadState. So instead we check for the thread having ended by seeing whether the `finally` block has assigned a value to its Results property; until then, Results is null. This should guarantee the safety of the existing GetTextFromQuery code, but to be safe we also make sure it can turn null into an empty string.
- Loading branch information