mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-23 13:30:02 +00:00
Properly clamp some iterative snprintf()s.
This commit is contained in:
parent
ebb9f68c3e
commit
fba0110073
@ -57,27 +57,27 @@ void GeDescribeVertexType(u32 op, char *buffer, int len) {
|
||||
char *w = buffer, *end = buffer + len;
|
||||
if (through)
|
||||
w += snprintf(w, end - w, "through, ");
|
||||
if (typeNames[tc])
|
||||
if (typeNames[tc] && w < end)
|
||||
w += snprintf(w, end - w, "%s texcoords, ", typeNames[tc]);
|
||||
if (colorNames[col])
|
||||
if (colorNames[col] && w < end)
|
||||
w += snprintf(w, end - w, "%s colors, ", colorNames[col]);
|
||||
if (typeNames[nrm])
|
||||
if (typeNames[nrm] && w < end)
|
||||
w += snprintf(w, end - w, "%s normals, ", typeNamesS[nrm]);
|
||||
if (typeNames[pos])
|
||||
if (typeNames[pos] && w < end)
|
||||
w += snprintf(w, end - w, "%s positions, ", typeNamesS[pos]);
|
||||
if (typeNames[weight])
|
||||
if (typeNames[weight] && w < end)
|
||||
w += snprintf(w, end - w, "%s weights (%d), ", typeNames[weight], weightCount);
|
||||
else if (weightCount > 0)
|
||||
else if (weightCount > 0 && w < end)
|
||||
w += snprintf(w, end - w, "unknown weights (%d), ", weightCount);
|
||||
if (morphCount > 0)
|
||||
if (morphCount > 0 && w < end)
|
||||
w += snprintf(w, end - w, "%d morphs, ", morphCount);
|
||||
if (typeNames[idx])
|
||||
if (typeNames[idx] && w < end)
|
||||
w += snprintf(w, end - w, "%s indexes, ", typeNames[idx]);
|
||||
|
||||
if (w < buffer + 2)
|
||||
snprintf(buffer, len, "none");
|
||||
// Otherwise, get rid of the pesky trailing comma.
|
||||
else
|
||||
else if (w < end)
|
||||
w[-2] = '\0';
|
||||
}
|
||||
|
||||
|
@ -905,12 +905,12 @@ void CtrlDisAsmView::copyInstructions(u32 startAddr, u32 endAddr, bool withDisas
|
||||
char *temp = new char[space];
|
||||
|
||||
char *p = temp, *end = temp + space;
|
||||
for (u32 pos = startAddr; pos < endAddr; pos += instructionSize)
|
||||
for (u32 pos = startAddr; pos < endAddr && p < end; pos += instructionSize)
|
||||
{
|
||||
p += snprintf(p, end - p, "%08X", debugger->readMemory(pos));
|
||||
|
||||
// Don't leave a trailing newline.
|
||||
if (pos + instructionSize < endAddr)
|
||||
if (pos + instructionSize < endAddr && p < end)
|
||||
p += snprintf(p, end - p, "\r\n");
|
||||
}
|
||||
W32Util::CopyTextToClipboard(wnd, temp);
|
||||
|
@ -314,7 +314,7 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
||||
char *temp = new char[space];
|
||||
|
||||
char *p = temp, *end = temp + space;
|
||||
for (u32 pos = selectRangeStart; pos < selectRangeEnd; pos += instructionSize)
|
||||
for (u32 pos = selectRangeStart; pos < selectRangeEnd && p < end; pos += instructionSize)
|
||||
{
|
||||
GPUDebugOp op = gpuDebug->DissassembleOp(pos);
|
||||
p += snprintf(p, end - p, "%s\r\n", op.desc.c_str());
|
||||
@ -351,7 +351,7 @@ void CtrlDisplayListView::onMouseUp(WPARAM wParam, LPARAM lParam, int button)
|
||||
char *temp = new char[space];
|
||||
|
||||
char *p = temp, *end = temp + space;
|
||||
for (u32 pos = selectRangeStart; pos < selectRangeEnd; pos += instructionSize)
|
||||
for (u32 pos = selectRangeStart; pos < selectRangeEnd && p < end; pos += instructionSize)
|
||||
p += snprintf(p, end - p, "%08X\r\n", Memory::ReadUnchecked_U32(pos));
|
||||
|
||||
W32Util::CopyTextToClipboard(wnd, temp);
|
||||
|
Loading…
Reference in New Issue
Block a user