/ Check-in [e390023c]
Login

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

Overview
Comment:In the command-line shell, always exit if realloc() fails.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: e390023c8e70961661fd9e29674dedacd1b941b6b8d9cd88f8cfa8f787f030f9
User & Date: drh 2018-07-29 18:56:35
Context
2018-08-03
13:56
Improve "PRAGMA vdbe_trace=ON" to always show the key values for the OP_IdxGT and related opcodes. check-in: 0f881955 user: drh tags: trunk
2018-07-29
18:56
In the command-line shell, always exit if realloc() fails. check-in: e390023c user: drh tags: trunk
2018-07-28
21:01
Add a small cost penalty to sorting to bias the query planner in favor of plans that do not require a final sorting pass. check-in: 85b9beb4 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/shell.c.in.

   564    564     int nLine = zLine==0 ? 0 : 100;
   565    565     int n = 0;
   566    566   
   567    567     while( 1 ){
   568    568       if( n+100>nLine ){
   569    569         nLine = nLine*2 + 100;
   570    570         zLine = realloc(zLine, nLine);
   571         -      if( zLine==0 ) return 0;
          571  +      if( zLine==0 ) shell_out_of_memory();
   572    572       }
   573    573       if( fgets(&zLine[n], nLine - n, in)==0 ){
   574    574         if( n==0 ){
   575    575           free(zLine);
   576    576           return 0;
   577    577         }
   578    578         zLine[n] = 0;
................................................................................
   591    591     ** multi-byte characterset characters into UTF-8. */
   592    592     if( stdin_is_interactive && in==stdin ){
   593    593       char *zTrans = sqlite3_win32_mbcs_to_utf8_v2(zLine, 0);
   594    594       if( zTrans ){
   595    595         int nTrans = strlen30(zTrans)+1;
   596    596         if( nTrans>nLine ){
   597    597           zLine = realloc(zLine, nTrans);
   598         -        if( zLine==0 ){
   599         -          sqlite3_free(zTrans);
   600         -          return 0;
   601         -        }
          598  +        if( zLine==0 ) shell_out_of_memory();
   602    599         }
   603    600         memcpy(zLine, zTrans, nTrans);
   604    601         sqlite3_free(zTrans);
   605    602       }
   606    603     }
   607    604   #endif /* defined(_WIN32) || defined(WIN32) */
   608    605     return zLine;
................................................................................
   741    738         if( zAppend[i]==quote ) len++;
   742    739       }
   743    740     }
   744    741   
   745    742     if( p->n+len>=p->nAlloc ){
   746    743       p->nAlloc = p->nAlloc*2 + len + 20;
   747    744       p->z = realloc(p->z, p->nAlloc);
   748         -    if( p->z==0 ){
   749         -      memset(p, 0, sizeof(*p));
   750         -      return;
   751         -    }
          745  +    if( p->z==0 ) shell_out_of_memory();
   752    746     }
   753    747   
   754    748     if( quote ){
   755    749       char *zCsr = p->z+p->n;
   756    750       *zCsr++ = quote;
   757    751       for(i=0; i<nAppend; i++){
   758    752         *zCsr++ = zAppend[i];
................................................................................
  2624   2618               sqlite3_reset(pSql);
  2625   2619               return;
  2626   2620             }
  2627   2621           }
  2628   2622         }
  2629   2623         nAlloc += 100;
  2630   2624         p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
         2625  +      if( p->aiIndent==0 ) shell_out_of_memory();
  2631   2626         abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
         2627  +      if( abYield==0 ) shell_out_of_memory();
  2632   2628       }
  2633   2629       abYield[iOp] = str_in_array(zOp, azYield);
  2634   2630       p->aiIndent[iOp] = 0;
  2635   2631       p->nIndent = iOp+1;
  2636   2632   
  2637   2633       if( str_in_array(zOp, azNext) ){
  2638   2634         for(i=p2op; i<iOp; i++) p->aiIndent[i] += 2;