Replace sprintf with asprintf for auto allocation

This commit is contained in:
ArtDev 2021-12-18 09:03:07 +03:00 committed by GitHub
parent b1fc61648b
commit 06b9393ad0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -668,16 +668,15 @@ void pojavTerminate() {
JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) { JNIEXPORT void JNICALL Java_net_kdt_pojavlaunch_utils_JREUtils_setupBridgeWindow(JNIEnv* env, jclass clazz, jobject surface) {
potatoBridge.androidWindow = ANativeWindow_fromSurface(env, surface); potatoBridge.androidWindow = ANativeWindow_fromSurface(env, surface);
char *ptrStr = malloc(sizeof(long)); char *ptrStr = asprintf("%ld", (long) potatoBridge.androidWindow);
sprintf(ptrStr, "%ld", (long) potatoBridge.androidWindow);
setenv("POJAV_WINDOW_PTR", ptrStr, 1); setenv("POJAV_WINDOW_PTR", ptrStr, 1);
free(ptrStr);
} }
void* pojavGetCurrentContext() { void* pojavGetCurrentContext() {
switch (config_renderer) { switch (config_renderer) {
case RENDERER_GL4ES: case RENDERER_GL4ES:
return (void *)eglGetCurrentContext_p(); return (void *)eglGetCurrentContext_p();
case RENDERER_VIRGL: case RENDERER_VIRGL:
case RENDERER_VK_ZINK: case RENDERER_VK_ZINK:
return (void *)OSMesaGetCurrentContext_p(); return (void *)OSMesaGetCurrentContext_p();