On Fri, 1 Aug 2025 03:18:16 GMT, Prasanta Sadhukhan <psadhuk...@openjdk.org> 
wrote:

>> And if it is 0, what would you do ?
>> Previously 0 meant it hadn't yet been initialized. Now it is always 
>> initialized.
>> 
>> You'd need to return it anyway even it was zero.
>
> Then I guess whoever is using the `nativeStrikePtr` should account for that 
> it can receive null or 0..
> I haven't seen all cases but one case I saw `getFontMetrics `calls 
> `getFontMetrics(getNativeStrikePtr())`
> and there it does this where it dereference `awtStrikePtr`...Shouldn't it 
> cause SIGSEGV if it ever becomes 0?
> 
> 
> JNIEXPORT jobject JNICALL
> Java_sun_font_CStrike_getFontMetrics
>     (JNIEnv *env, jclass clazz, jlong awtStrikePtr)
> {
>     jobject metrics = NULL;
> 
> JNI_COCOA_ENTER(env);
>     AWT_FONT_CLEANUP_SETUP;
> 
>     AWTFont *awtfont = ((AWTStrike *)jlong_to_ptr(awtStrikePtr))->fAWTFont;

Nothing is different than before.
We return the result of calling createNativeStrikePtr() both before and after 
this fix.
So this is a pre-existing issue and one that I am not sure is very likely.
It would require the native alloc for the Objective C object to fail. 
And it probably would require all callers to be ready to handle it.
Dealing with that pre-existing theoretical problem is well outside the scope of 
this.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/26397#discussion_r2248923672

Reply via email to