You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[AI Refactoring] VoiceControlClient 인식 결과 콜백의 IntPtr != null 항상-참 비교(CS0472) → NULL 포인터 가드 무력화 + 네이티브 콜백 내 예외 전파 크래시 경로 [Scope: src/Tizen.Uix.VoiceControl] (2026-08-09) #7798
// VoiceControlClient.cs — RecognitionResult add 경로s_resultDelegate=(ResultEventevt,IntPtrcmdList,IntPtrresult,IntPtruserData)=>{Log.Info(LogTag,"Recognition Result Event Triggered");if((cmdList!=null)&&(result!=null))// IntPtr(struct) vs null — 항상 true{RecognitionResultEventArgsargs=newRecognitionResultEventArgs(newRecognitionResult(evt,cmdList,result));_recognitionResult?.Invoke(null,args);}else{Log.Info(LogTag,"Recognition Result Event null received");// 도달 불가 (dead code)}};
cmdList/result는 값 타입 IntPtr이므로 != null 비교는 nullable-lifted 연산으로 컴파일러가 항상 true로 평가합니다(경고 CS0472). NULL 네이티브 포인터가 와도 else 분기는 절대 실행되지 않습니다.
같은 파일의 GetResult()용 콜백(s_resultCb)은 아예 가드 없이 new RecognitionResult(evt, cmdList, result)를 호출합니다.
Problem
Coding Guidelines / 결함 위험: 네이티브가 NULL cmdList를 전달하면 가드를 그대로 통과하여 RecognitionResult 생성자 → new VoiceCommandList(new SafeCommandListHandle(IntPtr.Zero)) → 내부 생성자의 VcCmdListForeachCommands(zero handle)가 InvalidParameter로 실패 → ExceptionFactory.CreateException예외가 네이티브 콜백 프레임 안에서 throw 됩니다. P/Invoke reverse-callback 경계를 넘는 예외 전파는 정의되지 않은 동작(대부분 프로세스 크래시)입니다.
Clean Code: else 분기("null received" 로그)는 도달 불가능한 dead code이며, 의도(NULL 방어)와 구현이 불일치합니다.
Proposed Improvement
IntPtr.Zero 비교로 가드를 정상화하고, GetResult() 콜백에도 동일 가드를 추가하며, 네이티브 경계를 넘는 예외가 없도록 콜백 본문을 방어합니다.
Before:
if((cmdList!=null)&&(result!=null))
After:
s_resultDelegate=(ResultEventevt,IntPtrcmdList,IntPtrresult,IntPtruserData)=>{Log.Info(LogTag,"Recognition Result Event Triggered");if(cmdList!=IntPtr.Zero&&result!=IntPtr.Zero){try{varargs=newRecognitionResultEventArgs(newRecognitionResult(evt,cmdList,result));_recognitionResult?.Invoke(null,args);}catch(Exceptione){// 네이티브 콜백 경계를 넘는 예외 전파는 UB — 로그로 봉인Log.Error(LogTag,$"Recognition Result Event handling failed: {e}");}}else{Log.Info(LogTag,"Recognition Result Event null received");}};
// GetResult() 콜백에도 동일 가드 적용s_resultCb=(ResultEventevt,IntPtrcmdList,IntPtrresult,IntPtruserData)=>{if(cmdList!=IntPtr.Zero&&result!=IntPtr.Zero){s_recognitionResult=newRecognitionResult(evt,cmdList,result);}};
Activity
github-actions commentedon Oct 8, 2026
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days