diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2021-02-05 11:55:47 +0100 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2021-02-05 11:55:47 +0100 |
commit | ca63004190a7c5d449c88e91f55f32a09f04ec7e (patch) | |
tree | 4e7dafdeb7e1a7e5ea68b359a6f1aaa8f1c5af2e /storage/connect | |
parent | 571294f954779c195763d996c3235ec979b4cdd9 (diff) | |
download | mariadb-git-ca63004190a7c5d449c88e91f55f32a09f04ec7e.tar.gz |
- Fix bug causing bnx base wrong after CheckMemory
Add negative array indexes starting from the last
modified: storage/connect/bson.cpp
modified: storage/connect/bsonudf.cpp
modified: storage/connect/json.cpp
Diffstat (limited to 'storage/connect')
-rw-r--r-- | storage/connect/bson.cpp | 3 | ||||
-rw-r--r-- | storage/connect/bsonudf.cpp | 2 | ||||
-rw-r--r-- | storage/connect/json.cpp | 16 |
3 files changed, 18 insertions, 3 deletions
diff --git a/storage/connect/bson.cpp b/storage/connect/bson.cpp index a494cf3166b..7b948164cfb 100644 --- a/storage/connect/bson.cpp +++ b/storage/connect/bson.cpp @@ -1138,6 +1138,9 @@ PBVAL BJSON::GetArrayValue(PBVAL bap, int n) CheckType(bap, TYPE_JAR); int i = 0; + if (n < 0) + n += GetArraySize(bap); + for (PBVAL bvp = GetArray(bap); bvp; bvp = GetNext(bvp), i++) if (i == n) return bvp; diff --git a/storage/connect/bsonudf.cpp b/storage/connect/bsonudf.cpp index 0a9d3813aeb..d85bc7042d3 100644 --- a/storage/connect/bsonudf.cpp +++ b/storage/connect/bsonudf.cpp @@ -3707,6 +3707,7 @@ char *bson_get_item(UDF_INIT *initid, UDF_ARGS *args, char *result, PUSH_WARNING("CheckMemory error"); goto fin; } else { + bnx.Reset(); jvp = bnx.MakeValue(args, 0, true); if (g->Mrr) { // First argument is a constant @@ -4052,6 +4053,7 @@ double bsonget_real(UDF_INIT *initid, UDF_ARGS *args, *is_null = 1; return 0.0; } else { + bnx.Reset(); jvp = bnx.MakeValue(args, 0); if ((p = bnx.GetString(jvp))) { diff --git a/storage/connect/json.cpp b/storage/connect/json.cpp index 0152a44fffa..ac5f5a122cc 100644 --- a/storage/connect/json.cpp +++ b/storage/connect/json.cpp @@ -58,11 +58,19 @@ char *GetJsonNull(void); /***********************************************************************/ /* IsNum: check whether this string is all digits. */ /***********************************************************************/ -bool IsNum(PSZ s) { - for (char* p = s; *p; p++) +bool IsNum(PSZ s) +{ + char* p = s; + + if (*p == '-') + p++; + + if (*p == ']') + return false; + else for (; *p; p++) if (*p == ']') break; - else if (!isdigit(*p) || *p == '-') + else if (!isdigit(*p)) return false; return true; @@ -1257,6 +1265,8 @@ PJVAL JARRAY::GetArrayValue(int i) { if (Mvals && i >= 0 && i < Size) return Mvals[i]; + else if (Mvals && i < 0 && i >= -Size) + return Mvals[Size + i]; else return NULL; } // end of GetValue |