Skip to content

Commit de170ef

Browse files
authored
Merge pull request #2687 from dolthub/fulghum/bugfix
Bug fix for out of bounds slice access
2 parents a2d93a0 + 7e0c8d0 commit de170ef

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

server/functions/json.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,10 @@ var json_in = framework.Function1{
4747
if json.Valid(unsafe.Slice(unsafe.StringData(input), len(input))) {
4848
return input, nil
4949
}
50-
return nil, pgtypes.ErrInvalidSyntaxForType.New("json", input[:10]+"...")
50+
if len(input) > 10 {
51+
input = input[:10] + "..."
52+
}
53+
return nil, pgtypes.ErrInvalidSyntaxForType.New("json", input)
5154
},
5255
}
5356

testing/PostgresDockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ RUN apt update -y && \
1313
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor -o /etc/apt/trusted.gpg.d/postgresql.gpg
1414
RUN apt update -y && \
1515
apt install -y \
16-
python3.8 \
16+
python3 \
1717
python3-pip \
1818
python3-psycopg2 \
1919
curl \

testing/go/types_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1218,6 +1218,14 @@ var typesTests = []ScriptTest{
12181218
{`"\ud83d\ude04\ud83d\udc36"`},
12191219
},
12201220
},
1221+
{
1222+
Query: `SELECT '{'::json`,
1223+
ExpectedErr: "invalid input syntax for type json",
1224+
},
1225+
{
1226+
Query: `SELECT '{"key": "value"'::json`,
1227+
ExpectedErr: "invalid input syntax for type json",
1228+
},
12211229
},
12221230
},
12231231
{

0 commit comments

Comments
 (0)