Skip to content

Commit

Permalink
Update locstr.h to fix issue dsw#18.
Browse files Browse the repository at this point in the history
Fix for issue dsw#18. As per the comments in locstr.h the str field is permitted to be NULL. This fix protects against NULL pointer dereference in the << operators. This allows elkhound/elkhound elkhound/examples/crash1.gr to pass (not segfault) on Mac OS X.
  • Loading branch information
sam-ellis authored Oct 15, 2016
1 parent 52ce3b5 commit b9663b0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ast/locstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class LocString {

// (read-only) string-like behavior
friend std::ostream& operator<< (std::ostream &os, LocString const &loc)
{ return os << loc.str; }
friend stringBuilder& operator<< (stringBuilder &sb, LocString const &loc)
{ return sb << loc.str; }
{ return os << (loc.isNonNull() ? loc.str : "NULL"); }
friend stringBuilder& operator<< (stringBuilder &sb, LocString const &loc)
{ return sb << (loc.isNonNull() ? loc.str : "NULL"); }
StringRef strref() const { return str; }
operator StringRef () const { return str; }
char operator [] (int index) const { return str[index]; }
Expand Down

0 comments on commit b9663b0

Please sign in to comment.