mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 13:11:39 +01:00
[pdb] Fix an uninitialized read, and add a test for it.
This was originally reported in pr32249, uncovered by PTVS-Studio. There was no code coverage for this path because it was difficult to construct odd-case PDB files that were not generated by cl. Now that we can write construct minimal PDB files from YAML, it's easy to construct fragments that generate whatever we want. In this patch I add a test that creates 2 type records. One with a unique name, and one without. I verify that we can go from PDB to Yaml with no errors. In a future patch I'd like to add something like llvm-pdbdump raw -lookup-type that will just dump one record and nothing else, which should make it a bit cleaner to find this kind of thing. llvm-svn: 298017
This commit is contained in:
parent
2b205f11e1
commit
ab975dc712
@ -67,12 +67,9 @@ static Error mapNameAndUniqueName(CodeViewRecordIO &IO, StringRef &Name,
|
||||
error(IO.mapStringZ(N));
|
||||
error(IO.mapStringZ(U));
|
||||
} else {
|
||||
size_t BytesNeeded = Name.size() + 1;
|
||||
StringRef N = Name;
|
||||
if (BytesNeeded > BytesLeft) {
|
||||
size_t BytesToDrop = std::min(N.size(), BytesToDrop);
|
||||
N = N.drop_back(BytesToDrop);
|
||||
}
|
||||
// Cap the length of the string at however many bytes we have available,
|
||||
// plus one for the required null terminator.
|
||||
auto N = StringRef(Name).take_front(BytesLeft - 1);
|
||||
error(IO.mapStringZ(N));
|
||||
}
|
||||
} else {
|
||||
|
26
test/DebugInfo/PDB/Inputs/longname-truncation.yaml
Normal file
26
test/DebugInfo/PDB/Inputs/longname-truncation.yaml
Normal file
File diff suppressed because one or more lines are too long
3
test/DebugInfo/PDB/pdb-longname-truncation.test
Normal file
3
test/DebugInfo/PDB/pdb-longname-truncation.test
Normal file
@ -0,0 +1,3 @@
|
||||
; For now just verify that this doesn't cause an error. Later we pdbdump can
|
||||
; do type lookup, we can verify that the name matches what we expect.
|
||||
; RUN: llvm-pdbdump yaml2pdb -pdb=%t.pdb %p/Inputs/longname-truncation.yaml
|
Loading…
x
Reference in New Issue
Block a user