Skip to content

Commit

Permalink
Merge pull request #1116 from LeoWoerteler/gh-1115
Browse files Browse the repository at this point in the history
GH-1115: NPE in `prof:variables()` when variable is not yet bound.
  • Loading branch information
ChristianGruen committed Mar 26, 2015
2 parents a961894 + 560e113 commit 92e3acc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions basex-core/src/main/java/org/basex/query/var/QueryStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ public void set(final Var var, final Value val, final QueryContext qc, final Inp
*/
public String dump() {
final StringBuilder sb = new StringBuilder(QueryText.DEBUGLOCAL + ':');
for(int i = end - 1; i >= 0; i--) {
sb.append(Prop.NL).append(" $").append(vars[i].name).append(" := ").append(stack[i]);
if(i == start && i > 0) sb.append(Prop.NL).append(QueryText.DEBUGGLOBAL + ':');
for(int i = end; --i >= 0;) {
if(vars[i] != null) {
sb.append(Prop.NL).append(" $").append(vars[i].name).append(" := ").append(stack[i]);
if(i == start && i > 0) sb.append(Prop.NL).append(QueryText.DEBUGGLOBAL + ':');
}
}
return sb.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public void variables() {
try {
System.setErr(NULL);
query("for $x in 1 to 2 return " + _PROF_VARIABLES.args(), "");
query(_PROF_VARIABLES.args() + ", let $x := random:double() return floor($x * $x)", "0");
} finally {
System.setErr(ERR);
}
Expand Down

0 comments on commit 92e3acc

Please sign in to comment.