Fixed segmentation fault with text representation

This commit is contained in:
Andrew Kane
2023-06-12 01:09:40 -07:00
parent e5a620e02c
commit 06c3e68bef
4 changed files with 14 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
## 0.4.4 (unreleased)
- Improved error message for malformed vector literal
- Fixed segmentation fault with text representation
- Fixed consecutive delimiters with text representation
## 0.4.3 (2023-06-10)

View File

@@ -194,7 +194,7 @@ vector_in(PG_FUNCTION_ARGS)
pt = strtok(NULL, ",");
}
if (*stringEnd != ']')
if (stringEnd == NULL || *stringEnd != ']')
ereport(ERROR,
(errcode(ERRCODE_INVALID_TEXT_REPRESENTATION),
errmsg("malformed vector literal: \"%s\"", lit),

View File

@@ -81,6 +81,16 @@ ERROR: malformed vector literal: "1,2,3"
LINE 1: SELECT '1,2,3'::vector;
^
DETAIL: Vector contents must start with "[".
SELECT '['::vector;
ERROR: malformed vector literal: "["
LINE 1: SELECT '['::vector;
^
DETAIL: Unexpected end of input.
SELECT '[,'::vector;
ERROR: malformed vector literal: "[,"
LINE 1: SELECT '[,'::vector;
^
DETAIL: Unexpected end of input.
SELECT '[]'::vector;
ERROR: vector must have at least 1 dimension
LINE 1: SELECT '[]'::vector;

View File

@@ -14,6 +14,8 @@ SELECT '[4e38,1]'::vector;
SELECT '[1,2,3'::vector;
SELECT '[1,2,3]9'::vector;
SELECT '1,2,3'::vector;
SELECT '['::vector;
SELECT '[,'::vector;
SELECT '[]'::vector;
SELECT '[1,]'::vector;
SELECT '[1a]'::vector;