Fossil SCM

Fix the hextoblob() function so that does not report out-of-memory if the size of the input string is zero bytes. This fixes the instances of "out-of-memory" reports when accessing the /alerts page without an argument.

drh 2018-08-16 02:03 trunk
Commit 5519c6b8fc5cee35adfb0648ec69866840b71336f254433ce74d638747ec31c7
1 file changed +1 -1
+1 -1
--- src/db.c
+++ src/db.c
@@ -968,11 +968,11 @@
968968
int nIn = sqlite3_value_bytes(argv[0]);
969969
unsigned char *zOut;
970970
if( zIn==0 ) return;
971971
if( nIn&1 ) return;
972972
if( !validate16((const char*)zIn, nIn) ) return;
973
- zOut = sqlite3_malloc64( nIn/2 );
973
+ zOut = sqlite3_malloc64( nIn/2 + 1 );
974974
if( zOut==0 ){
975975
sqlite3_result_error_nomem(context);
976976
return;
977977
}
978978
decode16(zIn, zOut, nIn);
979979
--- src/db.c
+++ src/db.c
@@ -968,11 +968,11 @@
968 int nIn = sqlite3_value_bytes(argv[0]);
969 unsigned char *zOut;
970 if( zIn==0 ) return;
971 if( nIn&1 ) return;
972 if( !validate16((const char*)zIn, nIn) ) return;
973 zOut = sqlite3_malloc64( nIn/2 );
974 if( zOut==0 ){
975 sqlite3_result_error_nomem(context);
976 return;
977 }
978 decode16(zIn, zOut, nIn);
979
--- src/db.c
+++ src/db.c
@@ -968,11 +968,11 @@
968 int nIn = sqlite3_value_bytes(argv[0]);
969 unsigned char *zOut;
970 if( zIn==0 ) return;
971 if( nIn&1 ) return;
972 if( !validate16((const char*)zIn, nIn) ) return;
973 zOut = sqlite3_malloc64( nIn/2 + 1 );
974 if( zOut==0 ){
975 sqlite3_result_error_nomem(context);
976 return;
977 }
978 decode16(zIn, zOut, nIn);
979

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button