References #2509: Fixed off-by-one error during filter serialization.

(cherry picked from commit 89b12a988e9237aa5bf9856e123a493be63b6af9)