IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 7619


Ignore:
Timestamp:
Jun 21, 2006, 12:46:02 PM (20 years ago)
Author:
magnier
Message:

fixed error in constraints for psImage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/mathtypes/psImage.c

    r7579 r7619  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.107 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-06-15 02:29:12 $
     11 *  @version $Revision: 1.108 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-06-21 22:46:02 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2323#include "psMemory.h"
    2424#include "psError.h"
     25#include "psAbort.h"
    2526#include "psImage.h"
    2627#include "psString.h"
     
    5859                      psElemType type)
    5960{
    60     psS32 area = 0;
    61     psS32 elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
    62     psS32 rowSize = numCols * elementSize;        // row size in bytes.
    63 
    64     area = numCols * numRows;
    65 
    66     if (area < 1) {
     61    int elementSize = PSELEMTYPE_SIZEOF(type);  // element size in bytes
     62    int rowSize = numCols * elementSize;        // row size in bytes.
     63
     64    if (numRows < 1) {
    6765        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
    6866                PS_ERRORTEXT_psImage_AREA_NEGATIVE,
     
    7068        return NULL;
    7169    }
     70    if (numCols < 1) {
     71        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     72                PS_ERRORTEXT_psImage_AREA_NEGATIVE,
     73                numRows, numCols);
     74        return NULL;
     75    }
     76
     77    long numBytes = numRows * numCols * elementSize;
    7278
    7379    psImage* image = (psImage* ) psAlloc(sizeof(psImage));
     
    7783    image->data.V = psAlloc(sizeof(psPtr ) * numRows);
    7884
    79     image->p_rawDataBuffer = psAlloc(area * elementSize);
     85    image->p_rawDataBuffer = psAlloc(numBytes);
    8086
    8187    // set the row pointers.
     
    249255            NATIVETYPE temp = va_arg (argp, NATIVETYPE); \
    250256            if ( temp < PS_MIN_##TTT || temp > PS_MAX_##TTT ) { \
    251                 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: Value out of Range.\n"); \
     257                psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Error: Value %d out of Range.\n", temp); \
     258                psAbort("pslib", "trapping bad value"); \
    252259                return false; \
    253260            } \
Note: See TracChangeset for help on using the changeset viewer.