IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 8816


Ignore:
Timestamp:
Sep 15, 2006, 4:38:25 AM (20 years ago)
Author:
rhl
Message:

1/ Fix off-by-one out-of-bound check (and ensure position >= 0)
2/ We only removed one element, so don't subtract (position-1)
elements from n.

Even with legal codes, error 2 followed by error 1 => SIGSEGV.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/types/psArray.c

    r8804 r8816  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.51 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2006-09-12 21:55:49 $
     11 *  @version $Revision: 1.52 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2006-09-15 14:38:25 $
    1313 *
    1414 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    164164    PS_ASSERT_PTR_NON_NULL(array, false);
    165165
    166     if (position > array->n) {
     166    if (position < 0 || position >= array->n) {
    167167        psError(PS_ERR_BAD_PARAMETER_NULL, true,
    168168                _("position > then the number of elements in the array."));
     
    174174    psFree(array->data[i]);
    175175    memmove(&array->data[i], &array->data[i + 1], (n - i - 1) * sizeof(psPtr));
    176     array->n = --i; // reset the array size to indicate the removed item(s)
     176    array->n--;    // reset the array size to indicate the removed item
    177177
    178178    return true;
Note: See TracChangeset for help on using the changeset viewer.