Skip to content

Commit

Permalink
Add guards for unsafe dereferencing (ref plotly#2687)
Browse files Browse the repository at this point in the history
* In drawData
* In supplyDefaultsUpdateCalc
  • Loading branch information
jacobq committed Jun 27, 2018
1 parent edc166f commit d8925f7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 10 additions & 4 deletions src/plot_api/subroutines.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,12 +542,18 @@ exports.drawData = function(gd) {
var i;

// remove old colorbars explicitly
for(i = 0; i < calcdata.length; i++) {
var trace = calcdata[i][0].trace;
if(trace.visible !== true || !trace._module.colorbar) {
fullLayout._infolayer.select('.cb' + trace.uid).remove();
if(calcdata && calcdata.length) {
for(i = 0; i < calcdata.length; i++) {
var trace = calcdata[i][0].trace;
if(trace.visible !== true || !trace._module.colorbar) {
fullLayout._infolayer.select('.cb' + trace.uid).remove();
}
}
}
else {
// Abort / reject
return Promise.reject('drawData aborting due to receiving invalid calcdata');
}

clearGlCanvases(gd);

Expand Down
2 changes: 1 addition & 1 deletion src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ plots.supplyDefaults = function(gd, opts) {
plots.supplyDefaultsUpdateCalc = function(oldCalcdata, newFullData) {
for(var i = 0; i < newFullData.length; i++) {
var newTrace = newFullData[i];
var cd0 = oldCalcdata[i][0];
var cd0 = oldCalcdata && oldCalcdata[i] && !oldCalcdata[i][0];
if(cd0 && cd0.trace) {
var oldTrace = cd0.trace;
if(oldTrace._hasCalcTransform) {
Expand Down

0 comments on commit d8925f7

Please sign in to comment.