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