Commits

Andrew Dunstan committed fb2ede2

Fix off by one error.

Bug report from David Wheeler.

  • Participants
  • Parent commits 99e7eeb

Comments (0)

Files changed (1)

File src/jsonfuncs.c

 		ereport(ERROR,
 				(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
 				 errmsg("cannot extract field from a non-object")));
-	/* initialize array count for this nesting level */
+	/* 
+	 * initialize array count for this nesting level 
+	 * Note: the lex_level seen by array_start is one less than that seen by
+	 * the elements of the array.
+	 */
 	if (_state->search_type == JSON_SEARCH_PATH &&
-		lex_level <= _state->npath)
+		lex_level < _state->npath)
 		_state->array_level_index[lex_level] = -1;
 }