| 344 | } |
| 345 | |
| 346 | bool Reader::readValue() { |
| 347 | // This is a non-reentrant way to support a stackLimit. Terrible! |
| 348 | // But this deprecated class has a security problem: Bad input can |
| 349 | // cause a seg-fault. This seems like a fair, binary-compatible way |
| 350 | // to prevent the problem. |
| 351 | if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue()."); |
| 352 | ++stackDepth_g; |
| 353 | |
| 354 | Token token; |
| 355 | skipCommentTokens(token); |
| 356 | bool successful = true; |
| 357 | |
| 358 | if (collectComments_ && !commentsBefore_.empty()) { |
| 359 | currentValue().setComment(commentsBefore_, commentBefore); |
| 360 | commentsBefore_ = ""; |
| 361 | } |
| 362 | |
| 363 | switch (token.type_) { |
| 364 | case tokenObjectBegin: |
| 365 | successful = readObject(token); |
| 366 | currentValue().setOffsetLimit(current_ - begin_); |
| 367 | break; |
| 368 | case tokenArrayBegin: |
| 369 | successful = readArray(token); |
| 370 | currentValue().setOffsetLimit(current_ - begin_); |
| 371 | break; |
| 372 | case tokenNumber: |
| 373 | successful = decodeNumber(token); |
| 374 | break; |
| 375 | case tokenString: |
| 376 | successful = decodeString(token); |
| 377 | break; |
| 378 | case tokenTrue: |
| 379 | { |
| 380 | Value v(true); |
| 381 | currentValue().swapPayload(v); |
| 382 | currentValue().setOffsetStart(token.start_ - begin_); |
| 383 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 384 | } |
| 385 | break; |
| 386 | case tokenFalse: |
| 387 | { |
| 388 | Value v(false); |
| 389 | currentValue().swapPayload(v); |
| 390 | currentValue().setOffsetStart(token.start_ - begin_); |
| 391 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 392 | } |
| 393 | break; |
| 394 | case tokenNull: |
| 395 | { |
| 396 | Value v; |
| 397 | currentValue().swapPayload(v); |
| 398 | currentValue().setOffsetStart(token.start_ - begin_); |
| 399 | currentValue().setOffsetLimit(token.end_ - begin_); |
| 400 | } |
| 401 | break; |
| 402 | case tokenArraySeparator: |
| 403 | case tokenObjectEnd: |
nothing calls this directly
no test coverage detected