/ 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 Side-by-Side Diffs Show Whitespace Changes Patch

Changes to ext/misc/json1.c.

   699    699   */
   700    700   static int jsonParse(
   701    701     JsonParse *pParse,           /* Initialize and fill this JsonParse object */
   702    702     sqlite3_context *pCtx,       /* Report errors here */
   703    703     const char *zJson            /* Input JSON text to be parsed */
   704    704   ){
   705    705     int i;
   706         -  if( zJson==0 ) return 1;
   707    706     memset(pParse, 0, sizeof(*pParse));
          707  +  if( zJson==0 ) return 1;
   708    708     pParse->zJson = zJson;
   709    709     i = jsonParseValue(pParse, 0);
          710  +  if( pParse->oom ) i = -1;
   710    711     if( i>0 ){
   711    712       while( isspace(zJson[i]) ) i++;
   712    713       if( zJson[i] ) i = -1;
   713    714     }
   714    715     if( i<0 ){
   715    716       if( pParse->oom && pCtx!=0 ) sqlite3_result_error_nomem(pCtx);
   716    717       jsonParseReset(pParse);
................................................................................
   749    750   /*
   750    751   ** Compute the parentage of all nodes in a completed parse.
   751    752   */
   752    753   static int jsonParseFindParents(JsonParse *pParse){
   753    754     u32 *aUp;
   754    755     assert( pParse->aUp==0 );
   755    756     aUp = pParse->aUp = sqlite3_malloc( sizeof(u32)*pParse->nNode );
   756         -  if( aUp==0 ) return SQLITE_NOMEM;
          757  +  if( aUp==0 ){
          758  +    pParse->oom = 1;
          759  +    return SQLITE_NOMEM;
          760  +  }
   757    761     jsonParseFillInParentage(pParse, 0, 0);
   758    762     return SQLITE_OK;
   759    763   }
   760    764   
   761    765   /* forward declaration */
   762    766   static JsonNode *jsonLookupAppend(JsonParse*,const char*,int*);
   763    767   
................................................................................
  1668   1672       }else{
  1669   1673         pNode = p->sParse.aNode;
  1670   1674       }
  1671   1675       p->i = (int)(pNode - p->sParse.aNode);
  1672   1676       p->eType = pNode->eType;
  1673   1677       if( p->eType>=JSON_ARRAY ){
  1674   1678         pNode->u.iKey = 0;
         1679  +      p->iEnd = p->i + pNode->n + 1;
  1675   1680         if( !p->bRecursive ) p->i++;
  1676         -      p->iEnd = p->i + pNode->n;
  1677   1681       }else{
  1678   1682         p->iEnd = p->i+1;
  1679   1683       }
  1680   1684     }
  1681   1685     return p->sParse.oom ? SQLITE_NOMEM : SQLITE_OK;
  1682   1686   }
  1683   1687