mirror of
https://gitlab.com/pholy/OSCAR-code.git
synced 2025-04-05 10:40:42 +00:00
Prevent potential buffer overrun in gLineChart
This commit is contained in:
parent
ee1960bb5d
commit
b4fb4695f0
@ -37,6 +37,8 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
int start_py=w.GetBottomMargin();
|
int start_py=w.GetBottomMargin();
|
||||||
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
int width=scrx-(w.GetLeftMargin()+w.GetRightMargin());
|
||||||
int height=scry-(w.GetTopMargin()+w.GetBottomMargin())-2;
|
int height=scry-(w.GetTopMargin()+w.GetBottomMargin())-2;
|
||||||
|
if (width<40)
|
||||||
|
return;
|
||||||
EventDataType miny,maxy;
|
EventDataType miny,maxy;
|
||||||
double minx,maxx;
|
double minx,maxx;
|
||||||
miny=w.min_y, maxy=w.max_y, maxx=w.max_x, minx=w.min_x;
|
miny=w.min_y, maxy=w.max_y, maxx=w.max_x, minx=w.min_x;
|
||||||
@ -125,9 +127,15 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
int total_visible=0;
|
int total_visible=0;
|
||||||
bool square_plot,accel;
|
bool square_plot,accel;
|
||||||
|
|
||||||
for (QVector<Session *>::iterator s=m_day->begin(); s!=m_day->end(); s++) {
|
QHash<ChannelID,QVector<EventList *> >::iterator ci;
|
||||||
QHash<ChannelID,QVector<EventList *> >::iterator ci=(*s)->eventlist.find(m_code);
|
|
||||||
if (ci==(*s)->eventlist.end()) continue;
|
for (int svi=0;svi<m_day->size();svi++) {
|
||||||
|
if (!(*m_day)[svi]) {
|
||||||
|
qWarning() << "gLineChart::Plot() NULL Session Record.. This should not happen";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ci=(*m_day)[svi]->eventlist.find(m_code);
|
||||||
|
if (ci==(*m_day)[svi]->eventlist.end()) continue;
|
||||||
|
|
||||||
QVector<EventList *> & evec=ci.value();
|
QVector<EventList *> & evec=ci.value();
|
||||||
num_points=0;
|
num_points=0;
|
||||||
@ -274,6 +282,18 @@ void gLineChart::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
int z=floor(px); // Hmmm... round may screw this up.
|
int z=floor(px); // Hmmm... round may screw this up.
|
||||||
if (z<minz) minz=z; // minz=First pixel
|
if (z<minz) minz=z; // minz=First pixel
|
||||||
if (z>maxz) maxz=z; // maxz=Last pixel
|
if (z>maxz) maxz=z; // maxz=Last pixel
|
||||||
|
if (minz<0) {
|
||||||
|
qDebug() << "gLineChart::Plot() minz<0 should never happen!! minz =" << minz;
|
||||||
|
minz=0;
|
||||||
|
}
|
||||||
|
if (maxz>width) {
|
||||||
|
qDebug() << "gLineChart::Plot() maxz>width" << "maxz = " << maxz << "width =" << width << "scrx =" <<scrx;
|
||||||
|
maxz=width;
|
||||||
|
}
|
||||||
|
if (maxz>max_drawlist_size) {
|
||||||
|
qDebug() << "gLineChart::Plot() maxz>max_drawlist_size!!!! maxz = " << maxz << " max_drawlist_size =" << max_drawlist_size;
|
||||||
|
maxz=max_drawlist_size;
|
||||||
|
}
|
||||||
|
|
||||||
// Update the Y pixel bounds.
|
// Update the Y pixel bounds.
|
||||||
if (py<m_drawlist[z].x()) m_drawlist[z].setX(py);
|
if (py<m_drawlist[z].x()) m_drawlist[z].setX(py);
|
||||||
|
@ -53,8 +53,8 @@ void gLineOverlayBar::Plot(gGraphWindow & w,float scrx,float scry)
|
|||||||
float bottom=start_py+25, top=start_py+height-25;
|
float bottom=start_py+25, top=start_py+height-25;
|
||||||
QColor & col=color[0];
|
QColor & col=color[0];
|
||||||
|
|
||||||
qint64 X;
|
double X;
|
||||||
qint64 Y;
|
double Y;
|
||||||
QHash<ChannelID,QVector<EventList *> >::iterator cei;
|
QHash<ChannelID,QVector<EventList *> >::iterator cei;
|
||||||
for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
|
for (QVector<Session *>::iterator s=m_day->begin();s!=m_day->end(); s++) {
|
||||||
cei=(*s)->eventlist.find(m_code);
|
cei=(*s)->eventlist.find(m_code);
|
||||||
|
@ -60,7 +60,7 @@ public:
|
|||||||
QVector<Session *>::iterator begin() { return sessions.begin(); }
|
QVector<Session *>::iterator begin() { return sessions.begin(); }
|
||||||
QVector<Session *>::iterator end() { return sessions.end(); }
|
QVector<Session *>::iterator end() { return sessions.end(); }
|
||||||
|
|
||||||
size_t size() { return sessions.size(); }
|
int size() { return sessions.size(); }
|
||||||
Machine *machine;
|
Machine *machine;
|
||||||
|
|
||||||
void OpenEvents();
|
void OpenEvents();
|
||||||
|
Loading…
Reference in New Issue
Block a user