final preparation

This commit is contained in:
vms 2021-04-12 14:45:55 +03:00
parent 2150b81cf6
commit 932bfb38a1
5 changed files with 17 additions and 5 deletions

View File

@ -1,4 +1,4 @@
(@interface it_version "0.19.0"
(@interface it_version "0.19.0")
;; Types
(@interface type (func

View File

@ -35,7 +35,7 @@ void sqlite3_exec_(
sqlite3_callback xCallback, /* Invoke this callback routine */
void *pArg /* First argument to xCallback() */
) __EXPORT_NAME(sqlite3_exec) {
zSql[zSql_len] = '\x00';
zSql = handle_input_string(zSql, zSql_len);
char *pzErrMsg = 0;
const int ret_code = sqlite3_exec(db, zSql, xCallback, pArg, &pzErrMsg);

View File

@ -3443,9 +3443,8 @@ void sqlite3_open_v2_(
char *zVfs, /* Name of VFS module to use */
int zVfs_len
) __EXPORT_NAME(sqlite3_open_v2) {
// this strings were allocated by the allocate function that allocates 1 byte more for null character
filename[filename_len] = '\x00';
zVfs[zVfs_len] = '\x00';
filename = handle_input_string(filename, filename_len);
zVfs = handle_input_string(zVfs, zVfs_len);
sqlite3 *ppDb;

View File

@ -4913,6 +4913,8 @@ void add_object_to_release(void *object);
void set_result_ptr(void *ptr);
void set_result_size(int size);
char *handle_input_string(char *str, int len);
#endif
#endif /* SQLITEINT_H */

View File

@ -43,6 +43,17 @@ void *get_result_ptr() {
return RESULT_PTR;
}
char *handle_input_string(char *str, int len) {
if (len == 0) {
free(str);
return NULL;
}
// this strings are supposed to be allocated by the allocate function, which allocates 1 byte more for null character
str[len] = '\x00';
return str;
}
int main() {
// the main purpose of this empty main is to initialize WASI subsystem
return 0;