/ Check-in [cc520414]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix minor glitches in the json1.c extension, mostly having to do with OOM behavior.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:cc5204149c4053b9e529a72102d8df0925ad1ea1
User & Date: drh 2015-08-23 20:44:59
Context
2015-08-23
20:48
Fix a comment typo on sqlite3ExprAlloc(). No code changes. check-in: 518d6220 user: drh tags: trunk
20:44
Fix minor glitches in the json1.c extension, mostly having to do with OOM behavior. check-in: cc520414 user: drh tags: trunk
02:42
Fixes to json_each() and json_tree(). Improved json_parse() debugging output. check-in: fc1b24f3 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to ext/misc/json1.c.

699
700
701
702
703
704
705
706
707

708
709

710
711
712
713
714
715
716
...
749
750
751
752
753
754
755


756

757
758
759
760
761
762
763
....
1668
1669
1670
1671
1672
1673
1674

1675
1676
1677
1678
1679
1680
1681
1682
1683
*/
static int jsonParse(
  JsonParse *pParse,           /* Initialize and fill this JsonParse object */
  sqlite3_context *pCtx,       /* Report errors here */
  const char *zJson            /* Input JSON text to be parsed */
){
  int i;
  if( zJson==0 ) return 1;
  memset(pParse, 0, sizeof(*pParse));

  pParse->zJson = zJson;
  i = jsonParseValue(pParse, 0);

  if( i>0 ){
    while( isspace(zJson[i]) ) i++;
    if( zJson[i] ) i = -1;
  }
  if( i<0 ){
    if( pParse->oom && pCtx!=0 ) sqlite3_result_error_nomem(pCtx);
    jsonParseReset(pParse);
................................................................................
/*
** Compute the parentage of all nodes in a completed parse.
*/
static int jsonParseFindParents(JsonParse *pParse){
  u32 *aUp;
  assert( pParse->aUp==0 );
  aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );


  if( aUp==0 ) return SQLITE_NOMEM;

  jsonParseFillInParentage(pParse, 0, 0);
  return SQLITE_OK;
}

/* forward declaration */
static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*);

................................................................................
    }else{
      pNode = p->sParse.aNode;
    }
    p->i = (int)(pNode - p->sParse.aNode);
    p->eType = pNode->eType;
    if( p->eType>=JSON_ARRAY ){
      pNode->u.iKey = 0;

      if( !p->bRecursive ) p->i++;
      p->iEnd = p->i + pNode->n;
    }else{
      p->iEnd = p->i+1;
    }
  }
  return p->sParse.oom ? SQLITE_NOMEM : SQLITE_OK;
}








<

>


>







 







>
>
|
>







 







>

<







699
700
701
702
703
704
705

706
707
708
709
710
711
712
713
714
715
716
717
...
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
....
1672
1673
1674
1675
1676
1677
1678
1679
1680

1681
1682
1683
1684
1685
1686
1687
*/
static int jsonParse(
  JsonParse *pParse,           /* Initialize and fill this JsonParse object */
  sqlite3_context *pCtx,       /* Report errors here */
  const char *zJson            /* Input JSON text to be parsed */
){
  int i;

  memset(pParse, 0, sizeof(*pParse));
  if( zJson==0 ) return 1;
  pParse->zJson = zJson;
  i = jsonParseValue(pParse, 0);
  if( pParse->oom ) i = -1;
  if( i>0 ){
    while( isspace(zJson[i]) ) i++;
    if( zJson[i] ) i = -1;
  }
  if( i<0 ){
    if( pParse->oom && pCtx!=0 ) sqlite3_result_error_nomem(pCtx);
    jsonParseReset(pParse);
................................................................................
/*
** Compute the parentage of all nodes in a completed parse.
*/
static int jsonParseFindParents(JsonParse *pParse){
  u32 *aUp;
  assert( pParse->aUp==0 );
  aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );
  if( aUp==0 ){
    pParse->oom = 1;
    return SQLITE_NOMEM;
  }
  jsonParseFillInParentage(pParse, 0, 0);
  return SQLITE_OK;
}

/* forward declaration */
static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*);

................................................................................
    }else{
      pNode = p->sParse.aNode;
    }
    p->i = (int)(pNode - p->sParse.aNode);
    p->eType = pNode->eType;
    if( p->eType>=JSON_ARRAY ){
      pNode->u.iKey = 0;
      p->iEnd = p->i + pNode->n + 1;
      if( !p->bRecursive ) p->i++;

    }else{
      p->iEnd = p->i+1;
    }
  }
  return p->sParse.oom ? SQLITE_NOMEM : SQLITE_OK;
}