IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17010


Ignore:
Timestamp:
Mar 17, 2008, 12:04:27 PM (18 years ago)
Author:
Paul Price
Message:

Adding checks on hdu to avoid SEGV.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/objects/pmSourceIO.c

    r16819 r17010  
    33 *  @author EAM, IfA
    44 *
    5  *  @version $Revision: 1.54 $ $Name: not supported by cvs2svn $
    6  *  @date $Date: 2008-03-05 01:08:08 $
     5 *  @version $Revision: 1.55 $ $Name: not supported by cvs2svn $
     6 *  @date $Date: 2008-03-17 22:04:27 $
    77 *
    88 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    278278        // a SPLIT format : only one header and object table per file
    279279        hdu = pmFPAviewThisHDU (view, file->fpa);
     280        if (!hdu) {
     281            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
     282            return false;
     283        }
    280284
    281285        // copy the header to an output header, add the output header data
     
    310314        // get the current header
    311315        hdu = pmFPAviewThisHDU (view, file->fpa);
    312 
    313         // determine the output table format
    314         psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
    315         if (!status) {
    316           psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
    317           return false;
    318         }
    319 
    320         // if this is not TRUE, the output files only contain the psf measurements.
    321         bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XSRC");
    322         bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XFIT");
     316        if (!hdu) {
     317            psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find HDU to write sources.");
     318            return false;
     319        }
     320
     321        // determine the output table format
     322        psMetadata *recipe = psMetadataLookupMetadata(&status, config->recipes, "PSPHOT");
     323        if (!status) {
     324          psError(PS_ERR_UNKNOWN, true, "missing recipe PSPHOT in config data");
     325          return false;
     326        }
     327
     328        // if this is not TRUE, the output files only contain the psf measurements.
     329        bool XSRC_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XSRC");
     330        bool XFIT_OUTPUT = psMetadataLookupBool(&status, recipe, "SAVE.XFIT");
    323331
    324332        // define the EXTNAME values for the different data segments:
     
    350358            dataname = pmFPAfileNameFromRule (rule, file, view);
    351359
    352             if (XSRC_OUTPUT) {
    353               // EXTNAME for extended source data table
    354               rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
    355               if (!rule) {
     360            if (XSRC_OUTPUT) {
     361              // EXTNAME for extended source data table
     362              rule = psMetadataLookupStr(&status, menu, "CMF.XSRC");
     363              if (!rule) {
    356364                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XSRC in EXTNAME.RULES in camera.config");
    357365                return false;
    358               }
    359               xsrcname = pmFPAfileNameFromRule (rule, file, view);
    360             }
    361             if (XFIT_OUTPUT) {
    362               // EXTNAME for extended source data table
    363               rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
    364               if (!rule) {
     366              }
     367              xsrcname = pmFPAfileNameFromRule (rule, file, view);
     368            }
     369            if (XFIT_OUTPUT) {
     370              // EXTNAME for extended source data table
     371              rule = psMetadataLookupStr(&status, menu, "CMF.XFIT");
     372              if (!rule) {
    365373                psError(PS_ERR_UNKNOWN, true, "missing entry for CMF.XFIT in EXTNAME.RULES in camera.config");
    366374                return false;
    367               }
    368               xfitname = pmFPAfileNameFromRule (rule, file, view);
    369             }
     375              }
     376              xfitname = pmFPAfileNameFromRule (rule, file, view);
     377            }
    370378        }
    371379
     
    416424            psFree (exttype);
    417425
    418             // if we request XSRC output, add the XSRC name to this header
    419             if (xsrcname) {
    420               psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
    421             }
    422             if (xfitname) {
    423               psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
    424             }
     426            // if we request XSRC output, add the XSRC name to this header
     427            if (xsrcname) {
     428              psMetadataAddStr (outhead, PS_LIST_TAIL, "XSRCNAME", PS_META_REPLACE, "name of XSRC table extension", xsrcname);
     429            }
     430            if (xfitname) {
     431              psMetadataAddStr (outhead, PS_LIST_TAIL, "XFITNAME", PS_META_REPLACE, "name of XFIT table extension", xfitname);
     432            }
    425433
    426434            // XXX these are case-sensitive since the EXTYPE is case-sensitive
     
    435443                status = pmSourcesWrite_PS1_DEV_1 (file->fits, sources, file->header, outhead, dataname, xsrcname);
    436444            }
    437             if (xsrcname) {
    438               if (!strcmp (exttype, "PS1_DEV_1")) {
     445            if (xsrcname) {
     446              if (!strcmp (exttype, "PS1_DEV_1")) {
    439447                status = pmSourcesWrite_PS1_DEV_1_XSRC (file->fits, sources, xsrcname);
    440               }
    441             }
    442             if (xfitname) {
    443               if (!strcmp (exttype, "PS1_DEV_1")) {
     448              }
     449            }
     450            if (xfitname) {
     451              if (!strcmp (exttype, "PS1_DEV_1")) {
    444452                status = pmSourcesWrite_PS1_DEV_1_XFIT (file->fits, sources, xfitname);
    445               }
    446             }
     453              }
     454            }
    447455            if (!status) {
    448456                psError(PS_ERR_IO, false, "writing CMF data to %s with format %s\n", file->filename, exttype);
Note: See TracChangeset for help on using the changeset viewer.