Changeset 5954


Ignore:
Timestamp:
02/25/04 03:06:52 (17 years ago)
Author:
piso
Message:

shrink(): avoid NPE if elements is null.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/j/src/org/armedbear/lisp/ComplexVector.java

    r5944 r5954  
    33 *
    44 * Copyright (C) 2002-2004 Peter Graves
    5  * $Id: ComplexVector.java,v 1.5 2004-02-24 22:35:46 piso Exp $
     5 * $Id: ComplexVector.java,v 1.6 2004-02-25 03:06:52 piso Exp $
    66 *
    77 * This program is free software; you can redistribute it and/or
     
    262262    public void shrink(int n) throws ConditionThrowable
    263263    {
    264         if (n < elements.length) {
    265             LispObject[] newArray = new LispObject[n];
    266             System.arraycopy(elements, 0, newArray, 0, n);
    267             elements = newArray;
    268             capacity = n;
    269             return;
    270         }
    271         if (n == elements.length)
    272             return;
     264        if (elements != null) {
     265            if (n < elements.length) {
     266                LispObject[] newArray = new LispObject[n];
     267                System.arraycopy(elements, 0, newArray, 0, n);
     268                elements = newArray;
     269                capacity = n;
     270                return;
     271            }
     272            if (n == elements.length)
     273                return;
     274        }
    273275        signal(new LispError());
    274276    }
Note: See TracChangeset for help on using the changeset viewer.