Skip to content

Commit

Permalink
fix: user_data should not deref
Browse files Browse the repository at this point in the history
  • Loading branch information
jhen0409 committed Dec 5, 2023
1 parent 8aebcfc commit 36244f4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions android/src/main/jni.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,13 @@ Java_com_rnwhisper_WhisperContext_fullTranscribe(
// abort handlers
rnwhisper::job job = rnwhisper::job_new(job_id);
params.encoder_begin_callback = [](struct whisper_context * /*ctx*/, struct whisper_state * /*state*/, void * user_data) {
rnwhisper::job job = *(rnwhisper::job*)user_data;
return !job.is_aborted();
rnwhisper::job *job = (rnwhisper::job*)user_data;
return !job->is_aborted();
};
params.encoder_begin_callback_user_data = &job;
params.abort_callback = [](void * user_data) {
rnwhisper::job job = *(rnwhisper::job*)user_data;
return job.is_aborted();
rnwhisper::job *job = (rnwhisper::job*)user_data;
return job->is_aborted();
};
params.abort_callback_user_data = &job;

Expand Down
8 changes: 4 additions & 4 deletions ios/RNWhisperContext.mm
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,13 @@ - (struct whisper_full_params)getParams:(NSDictionary *)options jobId:(int)jobId
// abort handler
rnwhisper::job job = rnwhisper::job_new(jobId);
params.encoder_begin_callback = [](struct whisper_context * /*ctx*/, struct whisper_state * /*state*/, void * user_data) {
rnwhisper::job job = *(rnwhisper::job*)user_data;
return !job.is_aborted();
rnwhisper::job *job = (rnwhisper::job*)user_data;
return !job->is_aborted();
};
params.encoder_begin_callback_user_data = &job;
params.abort_callback = [](void * user_data) {
rnwhisper::job job = *(rnwhisper::job*)user_data;
return job.is_aborted();
rnwhisper::job *job = (rnwhisper::job*)user_data;
return job->is_aborted();
};
params.abort_callback_user_data = &job;

Expand Down

0 comments on commit 36244f4

Please sign in to comment.