1
0
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:
Zachary Turner 2017-03-17 00:15:55 +00:00
parent 2b205f11e1
commit ab975dc712
3 changed files with 32 additions and 6 deletions

View File

@ -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 {

File diff suppressed because one or more lines are too long

View 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