sizeof with a pointer to dynamically allocated memory will return the size of the pointer, not the memory.
--HG-- extra : convert_revision : 04647d9fa0c464960d37797717f8171862cf48f8
This commit is contained in:
parent
a4a87daad1
commit
0cdcd207ac
|
@ -632,6 +632,7 @@ BaseRemoteGDB::trap(int type)
|
||||||
size_t datalen, len;
|
size_t datalen, len;
|
||||||
char data[GDBPacketBufLen + 1];
|
char data[GDBPacketBufLen + 1];
|
||||||
char *buffer;
|
char *buffer;
|
||||||
|
int bufferSize;
|
||||||
const char *p;
|
const char *p;
|
||||||
char command, subcmd;
|
char command, subcmd;
|
||||||
string var;
|
string var;
|
||||||
|
@ -640,7 +641,8 @@ BaseRemoteGDB::trap(int type)
|
||||||
if (!attached)
|
if (!attached)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
buffer = (char*)malloc(gdbregs.bytes() * 2 + 256);
|
bufferSize = gdbregs.bytes() * 2 + 256;
|
||||||
|
buffer = (char*)malloc(bufferSize);
|
||||||
|
|
||||||
DPRINTF(GDBMisc, "trap: PC=%#x NPC=%#x\n",
|
DPRINTF(GDBMisc, "trap: PC=%#x NPC=%#x\n",
|
||||||
context->readPC(), context->readNextPC());
|
context->readPC(), context->readNextPC());
|
||||||
|
@ -661,7 +663,7 @@ BaseRemoteGDB::trap(int type)
|
||||||
active = true;
|
active = true;
|
||||||
else
|
else
|
||||||
// Tell remote host that an exception has occurred.
|
// Tell remote host that an exception has occurred.
|
||||||
snprintf((char *)buffer, sizeof(buffer), "S%02x", type);
|
snprintf((char *)buffer, bufferSize, "S%02x", type);
|
||||||
send(buffer);
|
send(buffer);
|
||||||
|
|
||||||
// Stick frame regs into our reg cache.
|
// Stick frame regs into our reg cache.
|
||||||
|
@ -679,13 +681,13 @@ BaseRemoteGDB::trap(int type)
|
||||||
// if this command came from a running gdb, answer it --
|
// if this command came from a running gdb, answer it --
|
||||||
// the other guy has no way of knowing if we're in or out
|
// the other guy has no way of knowing if we're in or out
|
||||||
// of this loop when he issues a "remote-signal".
|
// of this loop when he issues a "remote-signal".
|
||||||
snprintf((char *)buffer, sizeof(buffer),
|
snprintf((char *)buffer, bufferSize,
|
||||||
"S%02x", type);
|
"S%02x", type);
|
||||||
send(buffer);
|
send(buffer);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case GDBRegR:
|
case GDBRegR:
|
||||||
if (2 * gdbregs.bytes() > sizeof(buffer))
|
if (2 * gdbregs.bytes() > bufferSize)
|
||||||
panic("buffer too small");
|
panic("buffer too small");
|
||||||
|
|
||||||
mem2hex(buffer, gdbregs.regs, gdbregs.bytes());
|
mem2hex(buffer, gdbregs.regs, gdbregs.bytes());
|
||||||
|
@ -732,7 +734,7 @@ BaseRemoteGDB::trap(int type)
|
||||||
send("E03");
|
send("E03");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (len > sizeof(buffer)) {
|
if (len > bufferSize) {
|
||||||
send("E04");
|
send("E04");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -768,7 +770,7 @@ BaseRemoteGDB::trap(int type)
|
||||||
send("E08");
|
send("E08");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
p = hex2mem(buffer, p, sizeof(buffer));
|
p = hex2mem(buffer, p, bufferSize);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
send("E09");
|
send("E09");
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue