OCC22105 Suspicious call to XOpenDisplay() in OSD_FontMgr class
authorAPL <>
Thu, 28 Apr 2011 15:04:33 +0000 (15:04 +0000)
committerbugmaster <bugmaster@opencascade.com>
Mon, 5 Mar 2012 15:27:49 +0000 (19:27 +0400)
src/OSD/OSD_FontMgr.cxx
src/OpenGl/OpenGl_TextRender.cxx

index 5b0f009..8756666 100755 (executable)
@@ -238,10 +238,15 @@ void OSD_FontMgr::InitFontDataBase() {
   Handle(TCollection_HAsciiString) str = new TCollection_HAsciiString;
   Display * disp = XOpenDisplay("localhost:0.0");
 
-  if ( !disp 
+  if (!disp
   {
-    cout << "Display is NULL!" << endl;
-    return ;
+    // let the X server find the available connection
+    disp = XOpenDisplay(":0.0");
+    if (!disp)
+    {
+      cout << "Display is NULL!" << endl;
+      return ;
+    }
   }
 
   Standard_Integer npaths = 0;
index 8576041..d25d4de 100755 (executable)
@@ -298,12 +298,6 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
   TsmGetAttri( 1, &keyZoom );
   zoom = keyZoom.data.ldata;
 
-  CMN_KEY keyfontName;
-  keyfontName.id = TelTextFont;//This flag responding about TextFontName
-  TsmGetAttri( 1, &keyfontName );
-  char *fontName = new char[strlen((char*)keyfontName.data.pdata) + 1];
-  strcpy(fontName,(char*)keyfontName.data.pdata);
-
   OpenGl_TextRender* textRender = OpenGl_TextRender::instance(); 
   int vh = 2 ;
   int vv = 2 ;
@@ -398,10 +392,17 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
   if ( renderMode == GL_FEEDBACK ) 
   {
 #ifdef HAVE_GL2PS
+    CMN_KEY keyfontName;
+    keyfontName.id = TelTextFont;//This flag responding about TextFontName
+    TsmGetAttri( 1, &keyfontName );
+    char *fontName = new char[strlen((char*)keyfontName.data.pdata) + 1];
+    strcpy(fontName,(char*)keyfontName.data.pdata);
+
     export_h = (GLdouble)fnt->FaceSize() / export_h;
     int aligment = alignmentforgl2ps( vh, vv );
     glPopMatrix();
     ExportText( str, fontName, export_h, angle, aligment, x, y, z, is2d!=0 );
+    delete [] fontName;
 #endif
   }
   else
@@ -409,7 +410,6 @@ void OpenGl_TextRender::RenderText ( char* str, GLuint base, int is2d, GLfloat x
     mgr->render_text( curFont, str );
     glPopMatrix();
   }
-  delete [] fontName;
   return;
 
 }