Skip to content

Commit 80adb27

Browse files
committed
misaligned pointer dereference: address must be a multiple of 0x8 but is 0x100384d7c', src/window.rs:92:15
1 parent b7333b4 commit 80adb27

File tree

6 files changed

+86
-212
lines changed

6 files changed

+86
-212
lines changed

examples/sum_int.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use libsqlite3_sys::sqlite3_int64;
55
use sqlite_loadable::prelude::*;
6-
use sqlite_loadable::window::{WindowFunctionCallbacks, define_window_function};
6+
use sqlite_loadable::window::define_window_function;
77
use sqlite_loadable::{api, Result};
88

99
/// Example inspired by sqlite3's sumint
@@ -16,7 +16,6 @@ pub fn x_step(context: *mut sqlite3_context, values: &[*mut sqlite3_value]) -> R
1616
Ok(())
1717
}
1818

19-
2019
pub fn x_final(context: *mut sqlite3_context) -> Result<()> {
2120
let value = api::get_aggregate_context_value::<sqlite3_int64>(context)?;
2221
api::result_int64(context, value);
@@ -41,8 +40,9 @@ pub fn x_inverse(context: *mut sqlite3_context, values: &[*mut sqlite3_value]) -
4140
#[sqlite_entrypoint]
4241
pub fn sqlite3_sumint_init(db: *mut sqlite3) -> Result<()> {
4342
let flags = FunctionFlags::UTF8 | FunctionFlags::DETERMINISTIC;
44-
define_window_function(db, "sumint", -1, flags,
45-
WindowFunctionCallbacks::new(x_step, x_final, x_value, x_inverse))?;
43+
define_window_function(
44+
db, "sumint", -1, flags,
45+
x_step, x_final, Some(x_value), Some(x_inverse))?;
4646
Ok(())
4747
}
4848

src/ext.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,19 +322,19 @@ pub unsafe fn sqlite3ext_create_window_function(
322322
argc: i32,
323323
text_rep: i32,
324324
p_app: *mut c_void,
325-
x_step: Option<unsafe extern "C" fn(*mut sqlite3_context, i32, *mut *mut sqlite3_value)>,
326-
x_final: Option<unsafe extern "C" fn(*mut sqlite3_context)>,
325+
x_step: unsafe extern "C" fn(*mut sqlite3_context, i32, *mut *mut sqlite3_value),
326+
x_final: unsafe extern "C" fn(*mut sqlite3_context),
327327
x_value: Option<unsafe extern "C" fn(*mut sqlite3_context)>,
328328
x_inverse: Option<unsafe extern "C" fn(*mut sqlite3_context, i32, *mut *mut sqlite3_value)>,
329329
destroy: Option<unsafe extern "C" fn(*mut c_void)>
330330
) -> c_int {
331331
if SQLITE3_API.is_null() {
332332
sqlite3_create_window_function(
333-
db, s, argc, text_rep, p_app, x_step, x_final, x_value, x_inverse, destroy,
333+
db, s, argc, text_rep, p_app, Some(x_step), Some(x_final), x_value, x_inverse, destroy,
334334
)
335335
} else {
336336
((*SQLITE3_API).create_window_function.expect(EXPECT_MESSAGE))(
337-
db, s, argc, text_rep, p_app, x_step, x_final, x_value, x_inverse, destroy,
337+
db, s, argc, text_rep, p_app, Some(x_step), Some(x_final), x_value, x_inverse, destroy,
338338
)
339339
}
340340
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub use bit_flags::FunctionFlags;
2727
pub use scalar::{define_scalar_function, define_scalar_function_with_aux};
2828

2929
#[doc(inline)]
30-
pub use window::{WindowFunctionCallbacksWithAux, define_window_function_with_aux};
30+
pub use window::define_window_function;
3131

3232
#[doc(inline)]
3333
pub use collation::define_collation;

src/scalar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ where
139139
let aux = (*x).1;
140140
// .collect slows things waaaay down, so stick with slice for now
141141
let args = slice::from_raw_parts(argv, argc as usize);
142-
let b = Box::from_raw(aux);
142+
let b: Box<T> = Box::from_raw(aux);
143143
match (*boxed_function)(context, args, &*b) {
144144
Ok(()) => (),
145145
Err(e) => {

0 commit comments

Comments
 (0)