| 326 | } |
| 327 | |
| 328 | bool Reader::readValue() { |
| 329 | // This is a non-reentrant way to support a stackLimit. Terrible! |
| 330 | // But this deprecated class has a security problem: Bad input can |
| 331 | // cause a seg-fault. This seems like a fair, binary-compatible way |
| 332 | // to prevent the problem. |
| 333 | if (stackDepth_g >= stackLimit_g) throwRuntimeError("Exceeded stackLimit in readValue()."); |
| 334 | ++stackDepth_g; |
| 335 | |
| 336 | Token token; |
| 337 | skipCommentTokens(token); |
| 338 | bool successful = true; |
| 339 | |
| 340 | if (collectComments_ && !commentsBefore_.empty()) { |
| 341 | currentValue().setComment(commentsBefore_, commentBefore); |
| 342 | commentsBefore_ = ""; |
| 343 | } |
| 344 | |
| 345 | switch (token.type_) { |
| 346 | case tokenObjectBegin: |
| 347 | successful = readObject(token); |
| 348 | break; |
| 349 | case tokenArrayBegin: |
| 350 | successful = readArray(token); |
| 351 | break; |
| 352 | case tokenNumber: |
| 353 | successful = decodeNumber(token); |
| 354 | break; |
| 355 | case tokenString: |
| 356 | successful = decodeString(token); |
| 357 | break; |
| 358 | case tokenTrue: { |
| 359 | Value v(true); |
| 360 | currentValue().swapPayload(v); |
| 361 | } break; |
| 362 | case tokenFalse: { |
| 363 | Value v(false); |
| 364 | currentValue().swapPayload(v); |
| 365 | } break; |
| 366 | case tokenNull: { |
| 367 | Value v; |
| 368 | currentValue().swapPayload(v); |
| 369 | } break; |
| 370 | // Else, fall through... |
| 371 | default: |
| 372 | return addError("Syntax error: value, object or array expected.", token); |
| 373 | } |
| 374 | |
| 375 | if (collectComments_) { |
| 376 | lastValueEnd_ = current_; |
| 377 | lastValue_ = ¤tValue(); |
| 378 | } |
| 379 | |
| 380 | --stackDepth_g; |
| 381 | return successful; |
| 382 | } |
| 383 | |
| 384 | void Reader::skipCommentTokens(Token& token) { |
| 385 | if (features_.allowComments_) { |
nothing calls this directly
no test coverage detected