mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-05 13:14:11 +08:00
Fix MG_EOO
This commit is contained in:
parent
d1828ecdb4
commit
1eed80375d
@ -2496,7 +2496,7 @@ int mg_json_get(const char *s, int len, const char *path, int *toklen) {
|
|||||||
// Ditto for `{` and `}`. Hence +2 in the code below.
|
// Ditto for `{` and `}`. Hence +2 in the code below.
|
||||||
#define MG_EOO(x) \
|
#define MG_EOO(x) \
|
||||||
do { \
|
do { \
|
||||||
if (depth == ed && ci != ei) return MG_JSON_NOT_FOUND; \
|
if (depth == ed && (ci != ei || ci < 0)) return MG_JSON_NOT_FOUND; \
|
||||||
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
||||||
depth--; \
|
depth--; \
|
||||||
MG_CHECKRET(x); \
|
MG_CHECKRET(x); \
|
||||||
|
@ -60,7 +60,7 @@ int mg_json_get(const char *s, int len, const char *path, int *toklen) {
|
|||||||
// Ditto for `{` and `}`. Hence +2 in the code below.
|
// Ditto for `{` and `}`. Hence +2 in the code below.
|
||||||
#define MG_EOO(x) \
|
#define MG_EOO(x) \
|
||||||
do { \
|
do { \
|
||||||
if (depth == ed && ci != ei) return MG_JSON_NOT_FOUND; \
|
if (depth == ed && (ci != ei || ci < 0)) return MG_JSON_NOT_FOUND; \
|
||||||
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
if (c != nesting[depth - 1] + 2) return MG_JSON_INVALID; \
|
||||||
depth--; \
|
depth--; \
|
||||||
MG_CHECKRET(x); \
|
MG_CHECKRET(x); \
|
||||||
|
@ -2317,7 +2317,7 @@ static void test_get_header_var(void) {
|
|||||||
static void test_json(void) {
|
static void test_json(void) {
|
||||||
const char *s;
|
const char *s;
|
||||||
const char *s1 = "{\"a\":{},\"b\":7,\"c\":[[],2]}";
|
const char *s1 = "{\"a\":{},\"b\":7,\"c\":[[],2]}";
|
||||||
const char *s2 = "{\"a\":{\"b1\":{}},\"c\":7}";
|
const char *s2 = "{\"a\":{\"b1\":{}},\"c\":7,\"d\":{\"b2\":{}}}";
|
||||||
int n, n1 = (int) strlen(s1), n2 = (int) strlen(s2);
|
int n, n1 = (int) strlen(s1), n2 = (int) strlen(s2);
|
||||||
|
|
||||||
ASSERT(mg_json_get(" true ", 6, "", &n) == MG_JSON_INVALID);
|
ASSERT(mg_json_get(" true ", 6, "", &n) == MG_JSON_INVALID);
|
||||||
|
Loading…
Reference in New Issue
Block a user