< prev index next >

src/java.desktop/unix/native/libsplashscreen/splashscreen_sys.c

Print this page

        

*** 795,852 **** void SplashReconfigure(Splash * splash) { sendctl(splash, SPLASHCTL_RECONFIGURE); } ! SPLASHEXPORT char* SplashGetScaledImageName(const char* jarName, const char* fileName, ! float *scaleFactor) { *scaleFactor = 1; #ifndef __linux__ ! return NULL; #endif *scaleFactor = getNativeScaleFactor(); if (*scaleFactor == 2.0) { - char *scaledImgName = NULL; size_t length = 0; char *stringToAppend = ".java-scale2x"; char *dupFileName = strdup(fileName); char *fileExtension = strrchr(dupFileName, '.'); if (fileExtension == NULL) { length = strlen(dupFileName) + strlen(stringToAppend) + 1; ! scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char)); int retVal = snprintf(scaledImgName, length, "%s%s", dupFileName, stringToAppend); ! if(retVal < 0 || (retVal != length - 1)) { ! free(scaledImgName); free(dupFileName); *scaleFactor = 1; ! return NULL; } } else { int length_without_ext = fileExtension - dupFileName; length = length_without_ext + strlen(stringToAppend) + strlen(fileExtension) + 1; ! scaledImgName = SAFE_SIZE_ARRAY_ALLOC(malloc, length, sizeof (char)); int retVal = snprintf(scaledImgName, length, "%.*s%s%s", length_without_ext, dupFileName, stringToAppend, fileExtension); ! if(retVal < 0 || retVal != length - 1) { ! free(scaledImgName); free(dupFileName); *scaleFactor = 1; ! return NULL; } } free(dupFileName); FILE *fp; if (!(fp = fopen(scaledImgName, "r"))) { *scaleFactor = 1; ! free(scaledImgName); ! return NULL; } fclose(fp); ! return scaledImgName; } ! return NULL; } - --- 795,856 ---- void SplashReconfigure(Splash * splash) { sendctl(splash, SPLASHCTL_RECONFIGURE); } ! SPLASHEXPORT jboolean SplashGetScaledImageName(const char* jarName, const char* fileName, ! float *scaleFactor, char *scaledImgName, ! const size_t scaledImageNameLength) { *scaleFactor = 1; #ifndef __linux__ ! return JNI_FALSE; #endif *scaleFactor = getNativeScaleFactor(); if (*scaleFactor == 2.0) { size_t length = 0; char *stringToAppend = ".java-scale2x"; char *dupFileName = strdup(fileName); char *fileExtension = strrchr(dupFileName, '.'); if (fileExtension == NULL) { length = strlen(dupFileName) + strlen(stringToAppend) + 1; ! if (length > scaledImageNameLength) { ! *scaleFactor = 1; ! free(dupFileName); ! return JNI_FALSE; ! } int retVal = snprintf(scaledImgName, length, "%s%s", dupFileName, stringToAppend); ! if (retVal < 0 || (retVal != length - 1)) { free(dupFileName); *scaleFactor = 1; ! return JNI_FALSE; } } else { int length_without_ext = fileExtension - dupFileName; length = length_without_ext + strlen(stringToAppend) + strlen(fileExtension) + 1; ! if (length > scaledImageNameLength) { ! *scaleFactor = 1; ! free(dupFileName); ! return JNI_FALSE; ! } int retVal = snprintf(scaledImgName, length, "%.*s%s%s", length_without_ext, dupFileName, stringToAppend, fileExtension); ! if (retVal < 0 || retVal != length - 1) { free(dupFileName); *scaleFactor = 1; ! return JNI_FALSE; } } free(dupFileName); FILE *fp; if (!(fp = fopen(scaledImgName, "r"))) { *scaleFactor = 1; ! return JNI_FALSE; } fclose(fp); ! return JNI_TRUE; } ! return JNI_FALSE; }
< prev index next >