|
From: <sv...@va...> - 2016-08-06 07:15:38
|
Author: sewardj
Date: Sat Aug 6 08:15:30 2016
New Revision: 15930
Log:
Fix invalid code caught by Ubsan, in which we compute the address
of "cgs->events[-1]", even though it isn't dereferenced.
Modified:
trunk/cachegrind/cg_main.c
trunk/callgrind/main.c
Modified: trunk/cachegrind/cg_main.c
==============================================================================
--- trunk/cachegrind/cg_main.c (original)
+++ trunk/cachegrind/cg_main.c Sat Aug 6 08:15:30 2016
@@ -914,7 +914,6 @@
static
void addEvent_Dw ( CgState* cgs, InstrInfo* inode, Int datasize, IRAtom* ea )
{
- Event* lastEvt;
Event* evt;
tl_assert(isIRAtom(ea));
@@ -924,15 +923,16 @@
return;
/* Is it possible to merge this write with the preceding read? */
- lastEvt = &cgs->events[cgs->events_used-1];
- if (cgs->events_used > 0
- && lastEvt->tag == Ev_Dr
- && lastEvt->Ev.Dr.szB == datasize
- && lastEvt->inode == inode
- && eqIRAtom(lastEvt->Ev.Dr.ea, ea))
- {
- lastEvt->tag = Ev_Dm;
- return;
+ if (cgs->events_used > 0) {
+ Event* lastEvt = &cgs->events[cgs->events_used-1];
+ if ( lastEvt->tag == Ev_Dr
+ && lastEvt->Ev.Dr.szB == datasize
+ && lastEvt->inode == inode
+ && eqIRAtom(lastEvt->Ev.Dr.ea, ea))
+ {
+ lastEvt->tag = Ev_Dm;
+ return;
+ }
}
/* No. Add as normal. */
Modified: trunk/callgrind/main.c
==============================================================================
--- trunk/callgrind/main.c (original)
+++ trunk/callgrind/main.c Sat Aug 6 08:15:30 2016
@@ -637,7 +637,6 @@
static
void addEvent_Dw ( ClgState* clgs, InstrInfo* inode, Int datasize, IRAtom* ea )
{
- Event* lastEvt;
Event* evt;
tl_assert(isIRAtom(ea));
tl_assert(datasize >= 1);
@@ -645,15 +644,16 @@
tl_assert(datasize <= CLG_(min_line_size));
/* Is it possible to merge this write with the preceding read? */
- lastEvt = &clgs->events[clgs->events_used-1];
- if (clgs->events_used > 0
- && lastEvt->tag == Ev_Dr
- && lastEvt->Ev.Dr.szB == datasize
- && lastEvt->inode == inode
- && eqIRAtom(lastEvt->Ev.Dr.ea, ea))
- {
- lastEvt->tag = Ev_Dm;
- return;
+ if (clgs->events_used > 0) {
+ Event* lastEvt = &clgs->events[clgs->events_used-1];
+ if ( lastEvt->tag == Ev_Dr
+ && lastEvt->Ev.Dr.szB == datasize
+ && lastEvt->inode == inode
+ && eqIRAtom(lastEvt->Ev.Dr.ea, ea))
+ {
+ lastEvt->tag = Ev_Dm;
+ return;
+ }
}
/* No. Add as normal. */
|