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.
Commit
5519c6b8fc5cee35adfb0648ec69866840b71336f254433ce74d638747ec31c7
Parent
a24de3f9fc4f3eb…
1 file changed
+1
-1
M
src/db.c
+1
-1
| --- src/db.c | ||
| +++ src/db.c | ||
| @@ -968,11 +968,11 @@ | ||
| 968 | 968 | int nIn = sqlite3_value_bytes(argv[0]); |
| 969 | 969 | unsigned char *zOut; |
| 970 | 970 | if( zIn==0 ) return; |
| 971 | 971 | if( nIn&1 ) return; |
| 972 | 972 | if( !validate16((const char*)zIn, nIn) ) return; |
| 973 | - zOut = sqlite3_malloc64( nIn/2 ); | |
| 973 | + zOut = sqlite3_malloc64( nIn/2 + 1 ); | |
| 974 | 974 | if( zOut==0 ){ |
| 975 | 975 | sqlite3_result_error_nomem(context); |
| 976 | 976 | return; |
| 977 | 977 | } |
| 978 | 978 | decode16(zIn, zOut, nIn); |
| 979 | 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 ); |
| 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 |