Changeset 12149


Ignore:
Timestamp:
09/18/09 06:22:41 (12 years ago)
Author:
Mark Evenson
Message:

Guard against null pointers in LispStackFrame? (Tobias Rittweiler).

Explicity create an UnavailableArgument? object to fill LispStackFrame?
objects which have null args members.

Location:
trunk/abcl/src/org/armedbear/lisp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/abcl/src/org/armedbear/lisp/LispObject.java

    r12111 r12149  
    633633  }
    634634
    635   public String unreadableString(String s)
     635  public String unreadableString(String s) {
     636     return unreadableString(s, true);
     637  }
     638  public String unreadableString(Symbol sym) throws ConditionThrowable {
     639     return unreadableString(sym, true);
     640  }
     641
     642  public String unreadableString(String s, boolean identity)
    636643  {
    637644    FastStringBuffer sb = new FastStringBuffer("#<");
    638645    sb.append(s);
    639     sb.append(" {");
    640     sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase());
    641     sb.append("}>");
     646    if (identity) {
     647      sb.append(" {");
     648      sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase());
     649      sb.append("}");
     650    }
     651    sb.append(">");
    642652    return sb.toString();
    643653  }
    644654
    645   public String unreadableString(Symbol symbol) throws ConditionThrowable
    646   {
    647     FastStringBuffer sb = new FastStringBuffer("#<");
    648     sb.append(symbol.writeToString());
    649     sb.append(" {");
    650     sb.append(Integer.toHexString(System.identityHashCode(this)).toUpperCase());
    651     sb.append("}>");
    652     return sb.toString();
     655  public String unreadableString(Symbol symbol, boolean identity)
     656    throws ConditionThrowable
     657  {
     658    return unreadableString(symbol.writeToString(), identity);
    653659  }
    654660
  • trunk/abcl/src/org/armedbear/lisp/LispStackFrame.java

    r12106 r12149  
    4343  private final LispObject[] args;
    4444
     45  private final class UnavailableArgument extends LispObject
     46  {
     47    public UnavailableArgument () { }
     48    @Override
     49    public String writeToString() {
     50      return unreadableString("unavailable arg", false);
     51    }
     52  }
     53
     54  private final LispObject UNAVAILABLE_ARG = new UnavailableArgument();
     55
    4556  public LispStackFrame(LispObject operator)
    4657  {
     
    109120       result =  unreadableString(LISP_STACK_FRAME + " "
    110121          + toLispString().getStringValue());
    111      } catch (ConditionThrowable t) {
    112        Debug.trace("Implementation error: ");
     122     } catch (Throwable t) {
     123       Debug.trace("Serious printing error: ");
    113124       Debug.trace(t);
    114125       result = unreadableString(LISP_STACK_FRAME);
     
    146157    if (args != null) {
    147158      for (int i = 0; i < args.length; i++)
    148   result = result.push(args[i]);
     159        // `args' come here from LispThread.execute. I don't know
     160        // how it comes that some callers pass NULL ptrs around but
     161        // we better do not create conses with their CAR being NULL;
     162        // it'll horribly break printing such a cons; and probably
     163        // other bad things may happen, too. --TCR, 2009-09-17.
     164        if (args[i] == null)
     165          result = result.push(UNAVAILABLE_ARG);
     166        else
     167          result = result.push(args[i]);
    149168    } else {
    150169      do {
     
    169188    throws ConditionThrowable
    170189  {
    171     return new SimpleString(toLispList().writeToString());
     190    String result;
     191    try {
     192      result = this.toLispList().writeToString();
     193    } catch (Throwable t) {
     194      Debug.trace("Serious printing error: ");
     195      Debug.trace(t);
     196      result = unreadableString("LISP-STACK-FRAME");
     197    }
     198    return new SimpleString(result);
    172199  }
    173200
Note: See TracChangeset for help on using the changeset viewer.