--- a/jdk/src/solaris/native/sun/awt/fontpath.c Tue Apr 16 21:19:02 2013 +0400
+++ b/jdk/src/solaris/native/sun/awt/fontpath.c Thu Apr 18 13:52:38 2013 +0100
@@ -41,6 +41,7 @@
#include <jni.h>
#include <jni_util.h>
#include <jvm_md.h>
+#include <sizecalc.h>
#ifndef HEADLESS
#include <X11/Xlib.h>
#include <awt.h>
@@ -225,7 +226,7 @@
if ( fDirP->num == 0 ) return;
- appendDirList = malloc ( fDirP->num * sizeof ( int ));
+ appendDirList = SAFE_SIZE_ARRAY_ALLOC(malloc, fDirP->num, sizeof ( int ));
if ( appendDirList == NULL ) {
return; /* if it fails we cannot do much */
}
@@ -282,7 +283,7 @@
}
- newFontPath = malloc ( totalDirCount * sizeof ( char **) );
+ newFontPath = SAFE_SIZE_ARRAY_ALLOC(malloc, totalDirCount, sizeof ( char **) );
/* if it fails free things and get out */
if ( newFontPath == NULL ) {
free ( ( void *) appendDirList );
@@ -303,7 +304,12 @@
/* printf ( "Appending %s\n", fDirP->name[index] ); */
- onePath = malloc ( ( strlen (fDirP->name[index]) + 2 )* sizeof( char ) );
+ onePath = SAFE_SIZE_ARRAY_ALLOC(malloc, strlen (fDirP->name[index]) + 2, sizeof( char ) );
+ if (onePath == NULL) {
+ free ( ( void *) appendDirList );
+ XFreeFontPath ( origFontPath );
+ return;
+ }
strcpy ( onePath, fDirP->name[index] );
strcat ( onePath, "/" );
newFontPath[nPaths++] = onePath;