Commit a9f0dbc
committed
Fix PQsetvalue() to avoid possible crash when adding a new tuple.
PQsetvalue unnecessarily duplicated the logic in pqAddTuple, and didn't
duplicate it exactly either --- pqAddTuple does not care what is in the
tuple-pointer array positions beyond the last valid entry, whereas the
code in PQsetvalue assumed such positions would contain NULL. This led
to possible crashes if PQsetvalue was applied to a PGresult that had
previously been enlarged with pqAddTuple, for instance one built from a
server query. Fix by relying on pqAddTuple instead of duplicating logic,
and not assuming anything about the contents of res->tuples[res->ntups].
Back-patch to 8.4, where PQsetvalue was introduced.
Andrew Chernow1 parent 0ce7676 commit a9f0dbc
1 file changed
+4
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
424 | 424 | | |
425 | 425 | | |
426 | 426 | | |
427 | | - | |
428 | | - | |
429 | | - | |
430 | | - | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | 427 | | |
448 | | - | |
| 428 | + | |
449 | 429 | | |
450 | 430 | | |
451 | 431 | | |
| |||
464 | 444 | | |
465 | 445 | | |
466 | 446 | | |
467 | | - | |
468 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
469 | 450 | | |
470 | 451 | | |
471 | 452 | | |
| |||
0 commit comments