forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita75a418
committed
Clean up dubious code in contrib/seg.
The restore() function assumed that the result of sprintf() with %e formatwould necessarily contain an 'e', which is false: what if the suppliednumber is an infinity or NaN? If that did happen, we'd get anull-pointer-dereference core dump. The case appears impossible currently,because seg_in() does not accept such values, and there are no seg-creatingfunctions that would create one. But it seems unwise to rely on it neverhappening in future.Quite aside from that, the code was pretty ugly: it relied on modifying astatic format string when it could use a "*" precision argument, and itused strtok() entirely gratuitously, and it stripped off trailing spacesby hand instead of just not asking for them to begin with.Coverity noticed the potential null pointer dereference (though I wonderwhy it didn't complain years ago, since this code is ancient).Since this is just code cleanup and forestalling a hypothetical futurebug, there seems no need for back-patching.1 parent8f75fd1 commita75a418
1 file changed
+19
-19
lines changedLines changed: 19 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
833 | 833 |
| |
834 | 834 |
| |
835 | 835 |
| |
836 |
| - | |
837 |
| - | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
838 | 839 |
| |
839 |
| - | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
840 | 844 |
| |
841 | 845 |
| |
842 | 846 |
| |
843 | 847 |
| |
844 |
| - | |
845 | 848 |
| |
846 | 849 |
| |
847 | 850 |
| |
| |||
856 | 859 |
| |
857 | 860 |
| |
858 | 861 |
| |
859 |
| - | |
860 |
| - | |
| 862 | + | |
| 863 | + | |
861 | 864 |
| |
862 | 865 |
| |
863 | 866 |
| |
864 | 867 |
| |
865 | 868 |
| |
866 | 869 |
| |
867 |
| - | |
868 |
| - | |
869 |
| - | |
870 |
| - | |
871 |
| - | |
| 870 | + | |
| 871 | + | |
872 | 872 |
| |
873 |
| - | |
874 |
| - | |
875 |
| - | |
| 873 | + | |
| 874 | + | |
876 | 875 |
| |
877 |
| - | |
878 |
| - | |
879 |
| - | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
880 | 879 |
| |
| 880 | + | |
881 | 881 |
| |
882 | 882 |
| |
883 |
| - | |
884 |
| - | |
| 883 | + | |
| 884 | + | |
885 | 885 |
| |
886 | 886 |
| |
887 | 887 |
| |
|
0 commit comments
Comments
(0)