Fossil

Check-in [20abe259]
Login

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

Overview
Comment:Pedantic cleanup to how to the SQL compress()/decompress() UDFs report an OOM, which can happen via zlib, outside of fossil's fail-fast allocator.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 20abe259639742fa8ae9519f070c4b850f34f54345ad300218a5d2ba5c70fce5
User & Date: stephan 2019-05-28 18:43:16
Context
2019-05-28
20:51
Add the login-group command for managing login groups from the command-line. check-in: c3ba504d user: drh tags: trunk
18:43
Pedantic cleanup to how to the SQL compress()/decompress() UDFs report an OOM, which can happen via zlib, outside of fossil's fail-fast allocator. check-in: 20abe259 user: stephan tags: trunk
2019-05-27
11:17
Fix a memory leak in the delta_parse() table-valued function, pointed out by Ralf Junkers. check-in: 9002a80a user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/sqlcmd.c.

82
83
84
85
86
87
88



89
90
91
92
93
94
95
...
111
112
113
114
115
116
117



118
119
120
121
122
123
124
  pOut[0] = nIn>>24 & 0xff;
  pOut[1] = nIn>>16 & 0xff;
  pOut[2] = nIn>>8 & 0xff;
  pOut[3] = nIn & 0xff;
  rc = compress(&pOut[4], &nOut, pIn, nIn);
  if( rc==Z_OK ){
    sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);



  }else{
    sqlite3_free(pOut);
    sqlite3_result_error(context, "input cannot be zlib compressed", -1);
  }
}

/*
................................................................................
  pIn = sqlite3_value_blob(argv[0]);
  nIn = sqlite3_value_bytes(argv[0]);
  nOut = (pIn[0]<<24) + (pIn[1]<<16) + (pIn[2]<<8) + pIn[3];
  pOut = sqlite3_malloc( nOut+1 );
  rc = uncompress(pOut, &nOut, &pIn[4], nIn-4);
  if( rc==Z_OK ){
    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);



  }else{
    sqlite3_free(pOut);
    sqlite3_result_error(context, "input is not zlib compressed", -1);
  }
}

/*







>
>
>







 







>
>
>







82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
  pOut[0] = nIn>>24 & 0xff;
  pOut[1] = nIn>>16 & 0xff;
  pOut[2] = nIn>>8 & 0xff;
  pOut[3] = nIn & 0xff;
  rc = compress(&pOut[4], &nOut, pIn, nIn);
  if( rc==Z_OK ){
    sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);
  }else if( rc==Z_MEM_ERROR ){
    sqlite3_free(pOut);
    sqlite3_result_error_nomem(context);
  }else{
    sqlite3_free(pOut);
    sqlite3_result_error(context, "input cannot be zlib compressed", -1);
  }
}

/*
................................................................................
  pIn = sqlite3_value_blob(argv[0]);
  nIn = sqlite3_value_bytes(argv[0]);
  nOut = (pIn[0]<<24) + (pIn[1]<<16) + (pIn[2]<<8) + pIn[3];
  pOut = sqlite3_malloc( nOut+1 );
  rc = uncompress(pOut, &nOut, &pIn[4], nIn-4);
  if( rc==Z_OK ){
    sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
  }else if( rc==Z_MEM_ERROR ){
    sqlite3_free(pOut);
    sqlite3_result_error_nomem(context);
  }else{
    sqlite3_free(pOut);
    sqlite3_result_error(context, "input is not zlib compressed", -1);
  }
}

/*