From 3e59fd7f2b55b60efd3c8deadffd15c8b7d68e53 Mon Sep 17 00:00:00 2001 From: William Joye Date: Fri, 14 Dec 2018 11:58:23 -0500 Subject: fix possible NULL ptr issue --- tksao/frame/grid25d.C | 8 +++++++- tksao/frame/grid2d.C | 7 ++++++- tksao/frame/grid3d.C | 7 +++++++ 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tksao/frame/grid25d.C b/tksao/frame/grid25d.C index e863490..53712fa 100644 --- a/tksao/frame/grid25d.C +++ b/tksao/frame/grid25d.C @@ -22,6 +22,7 @@ Grid25d::~Grid25d() int Grid25d::doit(RenderMode rm) { Frame3dBase* pp = (Frame3dBase*)parent_; + astGrid25dPtr =NULL; matrix_ = pp->widgetToCanvas; pixmap_ = pp->pixmap; @@ -54,6 +55,12 @@ int Grid25d::doit(RenderMode rm) break; default: { + // ast_ maybe NULL + if (!fits->ast_) { + astEnd; // now, clean up memory + return 1; + } + // set desired skyformat if (!fits->wcsInv()) { astEnd; // now, clean up memory @@ -70,7 +77,6 @@ int Grid25d::doit(RenderMode rm) case 1: // error astEnd; // now, clean up memory - astGrid25dPtr =NULL; return 0; case 2: break; diff --git a/tksao/frame/grid2d.C b/tksao/frame/grid2d.C index 923a2d1..499e4d0 100644 --- a/tksao/frame/grid2d.C +++ b/tksao/frame/grid2d.C @@ -22,6 +22,7 @@ Grid2d::~Grid2d() int Grid2d::doit(RenderMode rm) { FrameBase* pp = (FrameBase*)parent_; + astGrid2dPtr =NULL; matrix_ = pp->widgetToCanvas; pixmap_ = pp->pixmap; @@ -54,6 +55,11 @@ int Grid2d::doit(RenderMode rm) break; default: { + // ast_ maybe NULL + if (!fits->ast_) { + astEnd; // now, clean up memory + return 1; + } // set desired skyformat if (!fits->wcsInv()) { @@ -71,7 +77,6 @@ int Grid2d::doit(RenderMode rm) case 1: // error astEnd; // now, clean up memory - astGrid2dPtr =NULL; return 0; case 2: break; diff --git a/tksao/frame/grid3d.C b/tksao/frame/grid3d.C index 31440cf..91cfb69 100644 --- a/tksao/frame/grid3d.C +++ b/tksao/frame/grid3d.C @@ -22,6 +22,7 @@ Grid3d::~Grid3d() int Grid3d::doit(RenderMode rm) { Frame3dBase* pp = (Frame3dBase*)parent_; + astGrid3dPtr =NULL; mx_ = pp->refToWidget3d; rx_ = @@ -56,6 +57,12 @@ int Grid3d::doit(RenderMode rm) break; default: { + // ast_ maybe NULL + if (!fits->ast_) { + astEnd; // now, clean up memory + return 1; + } + if (!fits->wcsInv()) { astEnd; // now, clean up memory return 1; -- cgit v0.12