- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit131825c
committed
Code review for psql's helpSQL() function.
The loops to identify word boundaries could access past the end ofthe input string. Likely that would never result in an actualcrash, but it makes valgrind unhappy.The logic to try different numbers of words didn't work when theinput has two words but we only have a match to the first, eg"\h with select". (We must "continue" the pass loop, not "break".)The logic to compute nl_count was bizarrely managed, and in atleast two code paths could end up calling PageOutput withnl_count = 0, resulting in failing to paginate output that shouldhave been fed to the pager. Also, in v12 and up, the nl_countcalculation hadn't been updated to account for the addition of a URL.The PQExpBuffer holding the command syntax details wasn't freed,resulting in a session-lifespan memory leak.While here, improve some comments, choose a more descriptive namefor a variable, fix inconsistent datatype choice for another variable.Per bug #16837 from Alexander Lakhin. This code is very old,so back-patch to all supported branches.Kyotaro Horiguchi and Tom LaneDiscussion:https://postgr.es/m/16837-479bcd56040c71b3@postgresql.org1 parent41309f7 commit131825c
1 file changed
+36
-21
lines changedLines changed: 36 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
423 | 423 |
| |
424 | 424 |
| |
425 | 425 |
| |
| 426 | + | |
426 | 427 |
| |
427 | 428 |
| |
428 | 429 |
| |
| |||
460 | 461 |
| |
461 | 462 |
| |
462 | 463 |
| |
463 |
| - | |
464 |
| - | |
465 |
| - | |
| 464 | + | |
466 | 465 |
| |
467 | 466 |
| |
468 |
| - | |
469 |
| - | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
470 | 470 |
| |
471 | 471 |
| |
| 472 | + | |
472 | 473 |
| |
473 | 474 |
| |
474 | 475 |
| |
475 | 476 |
| |
476 | 477 |
| |
477 |
| - | |
| 478 | + | |
478 | 479 |
| |
479 |
| - | |
| 480 | + | |
480 | 481 |
| |
481 | 482 |
| |
482 | 483 |
| |
483 |
| - | |
| 484 | + | |
484 | 485 |
| |
485 |
| - | |
| 486 | + | |
486 | 487 |
| |
487 |
| - | |
488 |
| - | |
| 488 | + | |
| 489 | + | |
489 | 490 |
| |
490 | 491 |
| |
491 |
| - | |
| 492 | + | |
492 | 493 |
| |
493 |
| - | |
494 |
| - | |
495 |
| - | |
| 494 | + | |
| 495 | + | |
496 | 496 |
| |
497 | 497 |
| |
498 | 498 |
| |
499 | 499 |
| |
500 |
| - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
501 | 505 |
| |
502 | 506 |
| |
503 | 507 |
| |
504 | 508 |
| |
505 | 509 |
| |
| 510 | + | |
506 | 511 |
| |
507 | 512 |
| |
508 | 513 |
| |
509 | 514 |
| |
510 | 515 |
| |
511 | 516 |
| |
512 | 517 |
| |
| 518 | + | |
| 519 | + | |
| 520 | + | |
513 | 521 |
| |
514 | 522 |
| |
515 | 523 |
| |
| |||
523 | 531 |
| |
524 | 532 |
| |
525 | 533 |
| |
526 |
| - | |
| 534 | + | |
527 | 535 |
| |
528 | 536 |
| |
529 | 537 |
| |
530 | 538 |
| |
531 | 539 |
| |
532 | 540 |
| |
| 541 | + | |
| 542 | + | |
533 | 543 |
| |
534 | 544 |
| |
535 | 545 |
| |
536 | 546 |
| |
537 | 547 |
| |
538 |
| - | |
539 |
| - | |
| 548 | + | |
540 | 549 |
| |
541 | 550 |
| |
542 |
| - | |
543 |
| - | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
544 | 559 |
| |
545 | 560 |
| |
546 | 561 |
| |
|
0 commit comments
Comments
(0)