diff options
author | larrybr <larrybr@noemail.net> | 2022-11-22 22:46:41 +0000 |
---|---|---|
committer | larrybr <larrybr@noemail.net> | 2022-11-22 22:46:41 +0000 |
commit | 809be562184c5bb08508dc1e15fc9bd4668e1eed (patch) | |
tree | 5167cb5a4902d2d3ba10795ef61fe1e98c03ca1a /ext/misc/base64.c | |
parent | 411929025b6ebab6a6fecbee58ac6fae63040bdc (diff) | |
parent | c62052217504fe651505328c32ea024c554e8a08 (diff) | |
download | sqlite-809be562184c5bb08508dc1e15fc9bd4668e1eed.tar.gz sqlite-809be562184c5bb08508dc1e15fc9bd4668e1eed.zip |
Add more baseNN tests, get oversize error trapping working, and sync w/trunk
FossilOrigin-Name: 03819e9368fd9f78f351147a1dc865743f9634893e43a9d1e3d7cbaf4c966069
Diffstat (limited to 'ext/misc/base64.c')
-rw-r--r-- | ext/misc/base64.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/ext/misc/base64.c b/ext/misc/base64.c index dfeadcb16..6e3a6b5cb 100644 --- a/ext/misc/base64.c +++ b/ext/misc/base64.c @@ -187,14 +187,15 @@ static void base64(sqlite3_context *context, int na, sqlite3_value *av[]){ SQLITE_LIMIT_LENGTH, -1); char *cBuf; ubyte *bBuf; - assert(na==1); + assert(na==1); switch( sqlite3_value_type(av[0]) ){ case SQLITE_BLOB: nb = nv; nc = 4*(nv+2/3); /* quads needed */ nc += (nc+(B64_DARK_MAX-1))/B64_DARK_MAX + 1; /* LFs and a 0-terminator */ if( nvMax < nc ){ - sqlite3_result_error(context, "blob expanded to base64 too big.", -1); + sqlite3_result_error(context, "blob expanded to base64 too big", -1); + return; } cBuf = sqlite3_malloc(nc); if( !cBuf ) goto memFail; @@ -206,7 +207,8 @@ static void base64(sqlite3_context *context, int na, sqlite3_value *av[]){ nc = nv; nb = 3*((nv+3)/4); /* may overestimate due to LF and padding */ if( nvMax < nb ){ - sqlite3_result_error(context, "blob from base64 may be too big.", -1); + sqlite3_result_error(context, "blob from base64 may be too big", -1); + return; }else if( nb<1 ){ nb = 1; } @@ -217,8 +219,8 @@ static void base64(sqlite3_context *context, int na, sqlite3_value *av[]){ sqlite3_result_blob(context, bBuf, nb, sqlite3_free); break; default: - sqlite3_result_error(context, "base64 accepts only blob or text.", -1); - break; + sqlite3_result_error(context, "base64 accepts only blob or text", -1); + return; } return; memFail: |