LayerManagement: fixed issues detected by Coverity Scan
authorTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Thu, 31 May 2012 07:33:50 +0000 (09:33 +0200)
committerTimo Lotterbach <timo.lotterbach@bmw-carit.de>
Thu, 31 May 2012 07:33:50 +0000 (09:33 +0200)
35 files changed:
LayerManagerCommands/src/ShaderCreateCommand.cpp
LayerManagerCommands/src/ShaderDestroyCommand.cpp
LayerManagerExamples/EGLWLMockNavigation/include/Camera.h
LayerManagerExamples/EGLWLMockNavigation/include/MockNavi.h
LayerManagerExamples/EGLWLMockNavigation/include/ShaderLighting.h
LayerManagerExamples/EGLWLMockNavigation/src/Camera.cpp
LayerManagerExamples/EGLWLMockNavigation/src/ShaderBase.cpp
LayerManagerExamples/EGLX11MockNavigation/include/Camera.h
LayerManagerExamples/EGLX11MockNavigation/include/MockNavi.h
LayerManagerExamples/EGLX11MockNavigation/include/ShaderLighting.h
LayerManagerExamples/EGLX11MockNavigation/src/Camera.cpp
LayerManagerExamples/EGLX11MockNavigation/src/ShaderBase.cpp
LayerManagerExamples/LayerManagerToolBox/src/LayerManagerToolBox.cpp
LayerManagerExamples/LayerSceneDescriptionExample/src/LayerSceneProvider.cpp
LayerManagerPlugins/Communicators/DBUSCommunicator/include/DBUSMessageHandler.h
LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSCommunicator.cpp
LayerManagerPlugins/Communicators/DBUSCommunicator/src/DBUSMessageHandler.cpp
LayerManagerPlugins/Communicators/DBUSCommunicator/test/DBUSCommunicatorTest.cpp
LayerManagerPlugins/Renderers/Base/include/RenderUtil.h
LayerManagerPlugins/Renderers/Graphic/src/GraphicSystems/GLESGraphicSystem.cpp
LayerManagerPlugins/Renderers/Graphic/src/GraphicSystems/GLXGraphicSystem.cpp
LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11CopyGLX.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandX11WindowSystem.cpp
LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp
LayerManagerPlugins/Renderers/Platform/GLXRenderer/src/X11GLXRenderer.cpp
LayerManagerPlugins/Renderers/Platform/WaylandGLESRenderer/include/WaylandGLESRenderer.h
LayerManagerPlugins/Renderers/Platform/WaylandGLESRenderer/src/WaylandGLESRenderer.cpp
LayerManagerPlugins/Renderers/Platform/X11GLESRenderer/include/X11GLESRenderer.h
LayerManagerPlugins/Renderers/Platform/X11GLESRenderer/src/ShaderProgramGLES.cpp
LayerManagerPlugins/Renderers/Platform/X11GLESRenderer/src/X11GLESRenderer.cpp
LayerManagerService/include/Surface.h
LayerManagerService/src/Layermanager.cpp
LayerManagerService/src/main.cpp
LayerManagerService/src/shader/ShaderUniform.cpp

index a20c272..eaf73f2 100644 (file)
@@ -43,8 +43,8 @@ ExecutionResult ShaderCreateCommand::execute(ICommandExecutor* executor)
         if (renderer)
         {
             shader = renderer->createShader(&m_vertName, &m_fragName);
+            break;
         }
-        break;
     }
     if (shader)
     {
index 24d2460..e50664d 100644 (file)
@@ -30,12 +30,11 @@ ShaderDestroyCommand::ShaderDestroyCommand(unsigned int shaderid)
 ExecutionResult ShaderDestroyCommand::execute(ICommandExecutor* executor)
 {
     Scene& scene = *(executor->getScene());
-    ShaderMap& shaderMap = scene.m_shaderMap;
     ExecutionResult result = ExecutionFailed;
 
     // get shader by its ID
-    ShaderMapIterator iter = shaderMap.find(m_id);
-    ShaderMapIterator iterEnd = shaderMap.end();
+    ShaderMapIterator iter = scene.m_shaderMap.find(m_id);
+    ShaderMapIterator iterEnd = scene.m_shaderMap.end();
 
     if (iter == iterEnd)
     {
index 5ec44cf..aaf9011 100644 (file)
@@ -36,11 +36,10 @@ private:
     vec3f m_position;
     vec3f m_target;
     IlmMatrix m_viewProjectionMatrix;
-       IlmMatrix m_translationMatrix;
-       IlmMatrix m_rotationMatrix;
-       IlmMatrix m_projectionMatrix;
-       IlmMatrix m_identityMatrix;
-       IlmMatrix eyeMatrix;
+    IlmMatrix m_translationMatrix;
+    IlmMatrix m_rotationMatrix;
+    IlmMatrix m_projectionMatrix;
+    IlmMatrix m_identityMatrix;
 };
 
 #endif
index 30f9324..3708e43 100644 (file)
@@ -42,7 +42,6 @@ private:
 
 private:
     Camera m_camera;
-    int lastUpdateTime;
     int m_houseCount;
     list<IRenderable*> m_renderList;
     list<IUpdateable*> m_updateList;
index c4bef2a..1f74273 100644 (file)
@@ -29,8 +29,6 @@ public:
        virtual void use(vec3f* position, vec4f* color);
 
 private:
-       vec3f* m_pPosition;
-       vec4f* m_pColor;
        int m_uniformModelMatrix;
        int m_uniformColor;
 };
index 3ba753c..ad018b5 100644 (file)
@@ -36,6 +36,7 @@ Camera::Camera(vec3f position, vec3f target, float viewportWidth, float viewport
                         0.1f,                          // near
                         1000.0f,                       // far
                         viewportWidth/viewportHeight); // aspect ratio
+    m_viewProjectionMatrix = m_identityMatrix;
 }
 
 Camera::~Camera()
index 48bd485..02f40fc 100644 (file)
@@ -41,7 +41,7 @@ ShaderBase::~ShaderBase()
 
 bool ShaderBase::initShader()
 {
-    t_ilm_bool result = ILM_TRUE;
+    GLint glResult = GL_FALSE;
 
     // Create the fragment shader object
     fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
@@ -53,9 +53,9 @@ bool ShaderBase::initShader()
     // Compile the source code of fragment shader
     glCompileShader(fragmentShaderId);
 
-    glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+    glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -80,9 +80,9 @@ bool ShaderBase::initShader()
     // Compile the source code of fragment shader
     glCompileShader(vertexShaderId);
 
-    glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+    glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -106,9 +106,9 @@ bool ShaderBase::initShader()
 
     glLinkProgram(shaderProgramId);
 
-    glGetProgramiv(shaderProgramId, GL_LINK_STATUS, (GLint*) &result);
+    glGetProgramiv(shaderProgramId, GL_LINK_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -127,9 +127,9 @@ bool ShaderBase::initShader()
 #if 1 /* ADIT */
     glValidateProgram(shaderProgramId);
 
-    glGetProgramiv(shaderProgramId, GL_VALIDATE_STATUS, (GLint*) &result);
+    glGetProgramiv(shaderProgramId, GL_VALIDATE_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -151,16 +151,9 @@ bool ShaderBase::initShader()
 
     m_uniformProjectionMatrix = glGetUniformLocation(shaderProgramId, "u_projectionMatrix");
 
-    if (result)
-    {
-       cout << "Shader setup complete.\n";
-    }
-    else
-    {
-       cout << "Shader setup failed.\n";
-    }
+    cout << "Shader setup complete.\n";
 
-    return result;
+    return ILM_TRUE;
 }
 
 bool ShaderBase::destroyShader()
index 5ec44cf..aaf9011 100644 (file)
@@ -36,11 +36,10 @@ private:
     vec3f m_position;
     vec3f m_target;
     IlmMatrix m_viewProjectionMatrix;
-       IlmMatrix m_translationMatrix;
-       IlmMatrix m_rotationMatrix;
-       IlmMatrix m_projectionMatrix;
-       IlmMatrix m_identityMatrix;
-       IlmMatrix eyeMatrix;
+    IlmMatrix m_translationMatrix;
+    IlmMatrix m_rotationMatrix;
+    IlmMatrix m_projectionMatrix;
+    IlmMatrix m_identityMatrix;
 };
 
 #endif
index 30f9324..3708e43 100644 (file)
@@ -42,7 +42,6 @@ private:
 
 private:
     Camera m_camera;
-    int lastUpdateTime;
     int m_houseCount;
     list<IRenderable*> m_renderList;
     list<IUpdateable*> m_updateList;
index c4bef2a..1f74273 100644 (file)
@@ -29,8 +29,6 @@ public:
        virtual void use(vec3f* position, vec4f* color);
 
 private:
-       vec3f* m_pPosition;
-       vec4f* m_pColor;
        int m_uniformModelMatrix;
        int m_uniformColor;
 };
index 3ba753c..ad018b5 100644 (file)
@@ -36,6 +36,7 @@ Camera::Camera(vec3f position, vec3f target, float viewportWidth, float viewport
                         0.1f,                          // near
                         1000.0f,                       // far
                         viewportWidth/viewportHeight); // aspect ratio
+    m_viewProjectionMatrix = m_identityMatrix;
 }
 
 Camera::~Camera()
index 166c19e..271ed54 100644 (file)
@@ -41,7 +41,7 @@ ShaderBase::~ShaderBase()
 
 bool ShaderBase::initShader()
 {
-    t_ilm_bool result = ILM_TRUE;
+    GLint glResult = GL_FALSE;
 
     // Create the fragment shader object
     fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
@@ -53,9 +53,9 @@ bool ShaderBase::initShader()
     // Compile the source code of fragment shader
     glCompileShader(fragmentShaderId);
 
-    glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+    glGetShaderiv(fragmentShaderId, GL_COMPILE_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(fragmentShaderId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -80,9 +80,9 @@ bool ShaderBase::initShader()
     // Compile the source code of fragment shader
     glCompileShader(vertexShaderId);
 
-    glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, (GLint*) &result);
+    glGetShaderiv(vertexShaderId, GL_COMPILE_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(vertexShaderId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -106,9 +106,9 @@ bool ShaderBase::initShader()
 
     glLinkProgram(shaderProgramId);
 
-    glGetProgramiv(shaderProgramId, GL_LINK_STATUS, (GLint*) &result);
+    glGetProgramiv(shaderProgramId, GL_LINK_STATUS, &glResult);
 
-    if (!result)
+    if (glResult == GL_FALSE)
     {
         t_ilm_int infoLength, numberChars;
         glGetShaderiv(shaderProgramId, GL_INFO_LOG_LENGTH, &infoLength);
@@ -128,16 +128,9 @@ bool ShaderBase::initShader()
 
     m_uniformProjectionMatrix = glGetUniformLocation(shaderProgramId, "u_projectionMatrix");
 
-    if (result)
-    {
-       cout << "Shader setup complete.\n";
-    }
-    else
-    {
-       cout << "Shader setup failed.\n";
-    }
+    cout << "Shader setup complete.\n";
 
-    return result;
+    return ILM_TRUE;
 }
 
 bool ShaderBase::destroyShader()
index 8651661..6b782e5 100644 (file)
@@ -295,15 +295,15 @@ void showSurfaceProperties(t_param_struct *pStruct)
     printf("\tRendered frames\t: %i\n\n",surfaceProperties.frameCounter);    
 }
 
-
-
 bool fillLayerRenderOrder(char * param, t_param_struct* pStruct)
 {
     bool result = true;
     char * pRes = new char[strlen(param)+1];
     strcpy(pRes,param);
     int i = 0;
-    pRes = strtok (pRes,",");
+    char* tokens = strtok (pRes,",");
+    delete[] pRes;
+    pRes = tokens;
     while (pRes != NULL)
     {
         pRes = strtok (NULL, ",");
@@ -321,7 +321,10 @@ bool fillLayerRenderOrder(char * param, t_param_struct* pStruct)
         pStruct->layerro = new t_ilm_layer[i];
         pStruct->layerro_length = i;
         i = 0;
-        pRes = strtok (pRes,",");
+        tokens = strtok (pRes,",");
+        delete[] pRes;
+        pRes = tokens;
+
         printf("Set Renderorder : [\n");
         while (pRes != NULL)
         {
@@ -346,7 +349,7 @@ bool fillDimension(char * param, t_ilm_int *pArray)
     while (pos != std::string::npos)
     {
         std::string tempString = pRes.substr(0,pos);
-        printf("Dim param %s\n",tempString.c_str());        
+        printf("Dim param %s\n",tempString.c_str());
         tempArray[i++] = atoi(tempString.c_str());
         pRes = pRes.substr(pos+1);
         pos = pRes.find(",");
@@ -589,32 +592,34 @@ ilmErrorTypes listLayer(t_param_struct* param_struct)
     int i=0;
     if ( param_struct->screenid != -1 )
     {
-        error = ilm_getLayerIDsOnScreen(param_struct->screenid, &layerLength,&layerIds);
-    } else {
+        error = ilm_getLayerIDsOnScreen(param_struct->screenid, &layerLength, &layerIds);
+    }
+    else
+    {
         error = ilm_getLayerIDs(&layerLength,&layerIds);
     }
     if (layerLength > 0 && error == ILM_SUCCESS) 
     { 
-        printf("List Layer Ids for screen %i\n[\n",param_struct->screenid);
+        printf("List Layer Ids for screen %i\n[\n", param_struct->screenid);
         for (i=0;i<layerLength;i++) 
         {   
             t_ilm_int surfaceLength=0;
             t_ilm_surface* surfaceIds = NULL;
             int j=0;
             printf("\tLayer : 0x%08x\n",layerIds[i]);
-            ilm_getSurfaceIDsOnLayer(layerIds[i], &surfaceLength,&surfaceIds);
+            ilm_getSurfaceIDsOnLayer(layerIds[i], &surfaceLength, &surfaceIds);
             if (surfaceLength > 0 ) 
             {    
                 for (j=0;j<surfaceLength;j++) 
                 {   
                     printf("\t\tSurface : 0x%08x\n",surfaceIds[j]);
                 }
-                delete[] surfaceIds;
             }
+            delete[] surfaceIds;
         }
         printf("]\n");
-        delete [] layerIds;
     }
+    delete [] layerIds;
     return error;
 }
 
@@ -632,9 +637,9 @@ ilmErrorTypes listSurface(t_param_struct* param_struct)
         {   
             printf("\tSurface : 0x%08x\n",surfaceIds[j]);
         }
-        delete[] surfaceIds;
         printf("]\n");
     }
+    delete[] surfaceIds;
     return error;
 }
 
index 3f69de1..dffb9c1 100644 (file)
@@ -89,17 +89,17 @@ bool LayerSceneProvider::delegateScene()
         /* setup inital layer scenery */
         for (i = 0;i<numberOfLayers;i++)
         {
-            m_executor->execute(new LayerCreateCommand(screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer)));
-            m_executor->execute(new LayerSetSourceRectangleCommand(gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
-            m_executor->execute(new LayerSetDestinationRectangleCommand(gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
-            m_executor->execute(new LayerSetOpacityCommand(gInitialLayerScene[i].layer, gInitialLayerScene[i].opacity) );
-            m_executor->execute(new LayerSetVisibilityCommand(gInitialLayerScene[i].layer, gInitialLayerScene[i].visibility) );
-            m_executor->execute(new CommitCommand());
+            result &= m_executor->execute(new LayerCreateCommand(screenResolution[0], screenResolution[1], &(gInitialLayerScene[i].layer)));
+            result &= m_executor->execute(new LayerSetSourceRectangleCommand(gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
+            result &= m_executor->execute(new LayerSetDestinationRectangleCommand(gInitialLayerScene[i].layer, 0, 0, screenResolution[0], screenResolution[1]));
+            result &= m_executor->execute(new LayerSetOpacityCommand(gInitialLayerScene[i].layer, gInitialLayerScene[i].opacity) );
+            result &= m_executor->execute(new LayerSetVisibilityCommand(gInitialLayerScene[i].layer, gInitialLayerScene[i].visibility) );
+            result &= m_executor->execute(new CommitCommand());
             renderOrder[i]=gInitialLayerScene[i].layer;
         }        
         /* Finally set the first executed renderorder */
-        m_executor->execute(new ScreenSetRenderOrderCommand(renderOrder, numberOfLayers));
-        m_executor->execute(new CommitCommand());
+        result &= m_executor->execute(new ScreenSetRenderOrderCommand(renderOrder, numberOfLayers));
+        result &= m_executor->execute(new CommitCommand());
     }
     
     if ( numberOfSurfaces > 0 ) 
@@ -107,15 +107,14 @@ bool LayerSceneProvider::delegateScene()
         /* setup inital surface scenery */
         for (i = 0;i<numberOfSurfaces;i++)
         {
-            m_executor->execute(new SurfaceCreateCommand( &(gInitialSurfaceScene[i].surface)));
-            m_executor->execute(new SurfaceSetOpacityCommand(gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].opacity));
-            m_executor->execute(new SurfaceSetVisibilityCommand(gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].visibility));
-            m_executor->execute(new CommitCommand());
-
+            result &= m_executor->execute(new SurfaceCreateCommand( &(gInitialSurfaceScene[i].surface)));
+            result &= m_executor->execute(new SurfaceSetOpacityCommand(gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].opacity));
+            result &= m_executor->execute(new SurfaceSetVisibilityCommand(gInitialSurfaceScene[i].surface, gInitialSurfaceScene[i].visibility));
+            result &= m_executor->execute(new CommitCommand());
         }        
         /* Finally set the first executed renderorder */
     }
-    return result;    
+    return result;
 }
 
 extern "C" ISceneProvider* createLayerScene(ICommandExecutor* executor)
index acc222f..16d67e3 100644 (file)
@@ -65,7 +65,6 @@ private:
     dbus_uint32_t m_serial;
     DBusConnection* m_pConnection;
     DBusError m_err;
-    DBusObjectPathVTable m_objectPathVTable;
 };
 
 
index a1e990f..2e1ad2c 100644 (file)
@@ -2046,6 +2046,9 @@ DBusHandlerResult DBUSCommunicator::delegateMessage(DBusConnection* conn, DBusMe
     {
         result = DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     }
+
+    free(owner);
+
     return result;
 }
 
index 94d671a..9b46da4 100644 (file)
@@ -97,10 +97,12 @@ bool DBUSMessageHandler::registerPathFunction(  DBusObjectPathMessageFunction fM
                                                 void* comInstance)
 {
     bool result = true;
-    m_objectPathVTable.unregister_function = fUnregisterFunc;
-    m_objectPathVTable.message_function = fMessageFunc;        
+    DBusObjectPathVTable objectPathVTable;
+    memset(&objectPathVTable, 0, sizeof(objectPathVTable));
+    objectPathVTable.unregister_function = fUnregisterFunc;
+    objectPathVTable.message_function = fMessageFunc;
     
-    if (!dbus_connection_register_object_path(m_pConnection,DBUS_SERVICE_OBJECT_PATH,&m_objectPathVTable, comInstance) )
+    if (!dbus_connection_register_object_path(m_pConnection, DBUS_SERVICE_OBJECT_PATH, &objectPathVTable, comInstance) )
     {
         result = false;
     }    
@@ -158,7 +160,7 @@ void DBUSMessageHandler::ReplyError(DBusMessage* msg, const char* errorname, con
 
 char* DBUSMessageHandler::getString()
 {
-    char* param;
+    char* param = NULL;
 
     if (DBUS_TYPE_STRING != dbus_message_iter_get_arg_type(&m_MessageIter))
     {
@@ -174,7 +176,7 @@ char* DBUSMessageHandler::getString()
 
 dbus_bool_t DBUSMessageHandler::getBool()
 {
-    dbus_bool_t boolparam;
+    dbus_bool_t boolparam = FALSE;
 
     if (DBUS_TYPE_BOOLEAN != dbus_message_iter_get_arg_type(&m_MessageIter))
     {
@@ -190,7 +192,7 @@ dbus_bool_t DBUSMessageHandler::getBool()
 
 char DBUSMessageHandler::getByte()
 {
-    char param;
+    char param = 0;
 
     if (DBUS_TYPE_BYTE != dbus_message_iter_get_arg_type(&m_MessageIter))
     {
@@ -206,7 +208,7 @@ char DBUSMessageHandler::getByte()
 
 dbus_uint32_t DBUSMessageHandler::getUInt()
 {
-    dbus_uint32_t param;
+    dbus_uint32_t param = 0;
 
     if (DBUS_TYPE_UINT32 != dbus_message_iter_get_arg_type(&m_MessageIter))
     {
@@ -222,7 +224,7 @@ dbus_uint32_t DBUSMessageHandler::getUInt()
 
 double DBUSMessageHandler::getDouble()
 {
-    double param;
+    double param = 0.0;
 
     if (DBUS_TYPE_DOUBLE != dbus_message_iter_get_arg_type(&m_MessageIter))
     {
index af5955f..ba404f9 100644 (file)
@@ -58,7 +58,11 @@ public:
     MockCommandExecutor mockCommandExecutor;
     MockLayerList layerlist;
 
-    DBUSCommunicatorTest() {
+    DBUSCommunicatorTest()
+    : processThread(0)
+    , running(false)
+    , communicatorUnderTest(NULL)
+    {
     }
 
     virtual ~DBUSCommunicatorTest() {
@@ -86,9 +90,9 @@ public:
 
     void TearDown() {
         running = false;
-        this->communicatorUnderTest->stop();
-        pthread_join(processThread, NULL);
         if (communicatorUnderTest) {
+            this->communicatorUnderTest->stop();
+            pthread_join(processThread, NULL);
             delete communicatorUnderTest;
         }
     }
index c31c8bd..33b0ae1 100644 (file)
@@ -44,6 +44,14 @@ static char* RenderUtilLoadShaderFile(const char *szFilename)
 
     fseek(pFile, 0, SEEK_END);
     long size = ftell(pFile);
+
+    if (size < 0)
+    {
+        LOG_ERROR("RenderUtilLoadShaderFile","Unable get size of ShaderFile " << szFilename);
+        fclose(pFile);
+        return(NULL);
+    }
+
     fseek(pFile, 0, SEEK_SET);
 
     char *pBuffer = new char[size+1];
index 64e091d..58a69e3 100644 (file)
@@ -47,7 +47,23 @@ static const float vertices[8 * 12] =
 GLESGraphicsystem::GLESGraphicsystem(int windowWidth, int windowHeight, PfnShaderProgramCreator shaderProgram)
 : m_windowWidth(windowWidth)
 , m_windowHeight(windowHeight)
+, m_nativeDisplay(0)
+, m_nativeWindow(0)
 , m_shaderCreatorFunc(shaderProgram)
+, m_eglConfig(0)
+, m_eglContext(0)
+, m_eglSurface(0)
+, m_eglDisplay(0)
+, m_vbo(0)
+, m_displayWidth(0)
+, m_displayHeight(0)
+, m_blendingStatus(false)
+, m_defaultShader(0)
+, m_defaultShaderNoUniformAlpha(0)
+, m_currentLayer(0)
+#ifdef DRAW_LAYER_DEBUG
+, m_layerShader(0)
+#endif
 {
     LOG_DEBUG("GLESGraphicsystem", "creating GLESGraphicsystem");
 }
@@ -286,7 +302,7 @@ void GLESGraphicsystem::renderSurface(Surface* surface)
 
     ViewportTransform::applyLayerSource(layerSourceRegion, targetSurfaceSource, targetSurfaceDestination);
     ViewportTransform::applyLayerDestination(layerDestinationRegion, layerSourceRegion, targetSurfaceDestination);
-    float* textureCoordinates = new float[4];
+    float textureCoordinates[4];
     ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource, surface->OriginalSourceWidth, surface->OriginalSourceHeight, textureCoordinates);
 
     glBindBuffer(GL_ARRAY_BUFFER, m_vbo);
@@ -373,8 +389,6 @@ void GLESGraphicsystem::renderSurface(Surface* surface)
     {
         LOG_ERROR("GLESGraphicsystem", "GL Error occured :" << glErrorCode );
     };
-
-    delete[] textureCoordinates;
 }
 
 bool GLESGraphicsystem::initOpenGLES(EGLint displayWidth, EGLint displayHeight)
index d70c92e..939adc1 100644 (file)
 #include "Bitmap.h"
 
 GLXGraphicsystem::GLXGraphicsystem(int WindowWidth, int WindowHeight)
+: m_windowWidth(WindowWidth)
+, m_windowHeight(WindowHeight)
+, m_x11display(0)
+, m_window(0)
+, m_context(0)
+, m_currentLayer(0)
+, m_zerocopy(false)
+
 {
     LOG_DEBUG("GLXGraphicsystem", "creating GLXGraphicsystem");
-    this->m_windowHeight = WindowHeight;
-    this->m_windowWidth = WindowWidth;
-    m_zerocopy = false;
 }
 
 GLXGraphicsystem::~GLXGraphicsystem()
@@ -324,7 +329,7 @@ void GLXGraphicsystem::renderSurface(Surface* currentSurface)
 
     ViewportTransform::applyLayerSource(layerSourceRegion, targetSurfaceSource, targetSurfaceDestination);
     ViewportTransform::applyLayerDestination(layerDestinationRegion, layerSourceRegion, targetSurfaceDestination);
-    float* textureCoordinates = new float[4];
+    float textureCoordinates[4];
     ViewportTransform::transformRectangleToTextureCoordinates(targetSurfaceSource, currentSurface->OriginalSourceWidth, currentSurface->OriginalSourceHeight, textureCoordinates);
     
     glPushMatrix();
@@ -366,10 +371,9 @@ void GLXGraphicsystem::renderSurface(Surface* currentSurface)
     if ( GL_NO_ERROR != glErrorCode )
     {
         LOG_ERROR("GLXGraphicsystem", "GL Error occured :" << glErrorCode );
-    };    
-    currentSurface->frameCounter++;    
-    currentSurface->drawCounter++;    
-    delete[] textureCoordinates;
+    }
+    currentSurface->frameCounter++;
+    currentSurface->drawCounter++;
 }
 
 void GLXGraphicsystem::saveScreenShotOfFramebuffer(std::string fileToSave)
index 720e378..0ce9095 100644 (file)
@@ -26,7 +26,7 @@
 
 bool X11CopyGLX::bindSurfaceTexture(Surface* surface)
 {
-    XPlatformSurface* nativeSurface = (XPlatformSurface*)surface->platform;
+    XPlatformSurface* nativeSurface = NULL;
     Pixmap pixmap = 0;
     GLenum targetType = GL_BGRA;
     GLenum sourceType = GL_RGBA;
index e1ec1b5..90a0450 100644 (file)
@@ -107,16 +107,26 @@ extern "C" {
 
 WaylandBaseWindowSystem::WaylandBaseWindowSystem(const char* displayname, int width, int height, Scene* pScene)
 : BaseWindowSystem(pScene)
+, m_wlDisplay(NULL)
+, renderThread(0)
+, run_lock()
+, graphicSystem(NULL)
+, m_wlShm(NULL)
 , m_initialized(false)
 , m_takeScreenshot(ScreenShotNone)
 , m_displayname(displayname)
 , m_success(false)
 , m_systemState(IDLE_STATE)
 , m_manageConnectionId(256)
+, m_screenShotFile()
+, m_screenShotSurfaceID(0)
+, m_screenShotLayerID(0)
 , m_debugMode(false)
 , m_error(false)
 , m_width(width)
 , m_height(height)
+, m_listFrameCallback()
+, m_connectionList()
 {
     LOG_DEBUG("WaylandBaseWindowSystem", "creating WaylandBaseWindowSystem width:" << width << " height:" << height);
 
index c60ca18..0cdd4e9 100644 (file)
 
 WaylandX11WindowSystem::WaylandX11WindowSystem(const char* displayname, int width, int height, Scene* pScene)
 : WaylandBaseWindowSystem(displayname, width, height, pScene)
+, m_x11Window(0)
+, m_x11Display(0)
+, m_x11Screen(0)
+, m_x11Visual(0)
+, m_x11Colormap(0)
 {
     LOG_DEBUG("WaylandX11WindowSystem", "creating WaylandX11WindowSystem width:" << width << " height:" << height);
 }
@@ -85,7 +90,7 @@ bool WaylandX11WindowSystem::initGraphicSystem()
 bool WaylandX11WindowSystem::createNativeContext()
 {
     bool result = true;
-    Window rootWindow = NULL;
+    Window rootWindow = 0;
     XSetWindowAttributes windowAttributes;
     unsigned int windowMask = 0;
     int colorDepth = 0;
index cdd7b05..aec0878 100644 (file)
@@ -42,17 +42,35 @@ bool    X11WindowSystem::m_xerror = false;
 X11WindowSystem::X11WindowSystem(const char* displayname, int width, int height, Scene* pScene,GetVisualInfoFunction func)
 : BaseWindowSystem(pScene)
 , takeScreenshot(ScreenShotNone)
+, screenShotFile()
+, screenShotSurfaceID(0)
+, screenShotLayerID()
 , displayname(displayname)
 , getVisualFunc(func)
 , debugMode(false)
 , resolutionWidth(width)
 , resolutionHeight(height)
+, composite_event(0)
+, composite_error(0)
+, composite_major(0)
+, composite_minor(0)
+, damage_event(0)
+, damage_error(0)
+, damage_major(0)
+, damage_minor(0)
+, m_running(false)
 , m_initialized(false)
 , m_success(false)
 , m_systemState(IDLE_STATE)
 , m_displayEnvironment(NULL)
+, x11Display(0)
+, renderThread(0)
 , windowWidth(width)
 , windowHeight(height)
+, CompositorWindow(0)
+, windowVis(0)
+, run_lock()
+, graphicSystem(0)
 {
     LOG_DEBUG("X11WindowSystem", "creating X11WindowSystem");
 
@@ -374,18 +392,20 @@ void X11WindowSystem::NewWindow(Surface* surface, Window window)
         char* name;
         status = XFetchName(x11Display, window, &name);
         LOG_DEBUG("X11WindowSystem", "Got window name");
-        if (status >= Success)
+        if (status >= Success && name)
         {
-            LOG_DEBUG("X11WindowSystem", "Found window: " << window << "  " << name);
+            LOG_DEBUG("X11WindowSystem", "Found window: " << window << " " << name);
             char GuiTitle[]  = "Layermanager Remote GUI\0";
-            if (name != NULL && strcmp(name,GuiTitle)==0)
+            if (strcmp(name,GuiTitle)==0)
             {
                 LOG_DEBUG("X11WindowSystem", "Found gui window: repositioning it");
                 XCompositeUnredirectWindow(x11Display,window,CompositeRedirectManual);
                 XMoveWindow(x11Display, window, 50, 500);
                 XMapRaised(x11Display, window);
             }
-        }else {
+        }
+        else
+        {
             LOG_DEBUG("X11WindowSystem", "Error fetching window name");
         }
         LOG_DEBUG("X11WindowSystem","Creating New Damage for window - " << window);
index 8ebfee0..6c88aee 100644 (file)
@@ -30,6 +30,8 @@ X11GLXRenderer::X11GLXRenderer(Scene* pScene)
 : BaseRenderer(pScene)
 , m_pWindowSystem(0)
 , m_pGraphicSystem(0)
+, m_width(0)
+, m_height(0)
 {
 }
 
@@ -50,25 +52,30 @@ bool X11GLXRenderer::start(int width, int height, const char* displayname)
     if ( m_pWindowSystem->init(m_pGraphicSystem ) )
     {
         Display* x11Display = m_pWindowSystem->getNativeDisplayHandle();
-        GLXFBConfig *currentConfig = m_pGraphicSystem->GetMatchingPixmapConfig(x11Display);
-        if (x11Display != NULL && currentConfig != NULL )
+        if (x11Display)
         {
-            LOG_INFO("X11GLXRenderer", "Initialization successfull.");
-#ifdef WITH_FORCE_COPY
-            binder = new X11CopyGLX(x11Display);
-#else // WITH_FORCE_COPY
-            if ( m_pGraphicSystem->isZeroCopyEnabled() == true ) 
+            GLXFBConfig *currentConfig = m_pGraphicSystem->GetMatchingPixmapConfig(x11Display);
+            if (currentConfig)
             {
-                binder = new X11TextureFromPixmap(x11Display, *currentConfig);
-            } else {
+                LOG_INFO("X11GLXRenderer", "Initialization successful.");
+#ifdef WITH_FORCE_COPY
                 binder = new X11CopyGLX(x11Display);
-            }
+#else // WITH_FORCE_COPY
+                if (m_pGraphicSystem->isZeroCopyEnabled())
+                {
+                    binder = new X11TextureFromPixmap(x11Display, *currentConfig);
+                }
+                else
+                {
+                    binder = new X11CopyGLX(x11Display);
+                }
 #endif // WITH_FORCE_COPY
-            if ( binder != NULL ) 
-            {
-                m_pGraphicSystem->setTextureBinder(binder);
-                result = m_pWindowSystem->start();
-            } 
+                if ( binder != NULL )
+                {
+                    m_pGraphicSystem->setTextureBinder(binder);
+                    result = m_pWindowSystem->start();
+                }
+            }
         }
     }
     return result;
@@ -136,7 +143,7 @@ uint* X11GLXRenderer::getScreenIDs(uint* length)
 
 void X11GLXRenderer::signalWindowSystemRedraw()
 {
-       m_pWindowSystem->signalRedrawEvent();
+    m_pWindowSystem->signalRedrawEvent();
 }
 
 void X11GLXRenderer::forceCompositionWindowSystem()
@@ -145,7 +152,7 @@ void X11GLXRenderer::forceCompositionWindowSystem()
 }
 
 extern "C" IRenderer* createX11GLXRenderer(Scene* pScene) {
-       return new X11GLXRenderer(pScene);
+    return new X11GLXRenderer(pScene);
 }
 
 extern "C" void destroyX11GLXRenderer(X11GLXRenderer* p)
index 87b3e5b..3d459af 100644 (file)
@@ -26,6 +26,8 @@
 #include "GraphicSystems/GLESGraphicSystem.h"
 #include "WindowSystems/WaylandBaseWindowSystem.h"
 
+class ITextureBinder;
+
 class WaylandGLESRenderer : public BaseRenderer
 {
 public:
@@ -47,6 +49,7 @@ private:
     GLESGraphicsystem* m_pGraphicSystem;
     uint m_width;
     uint m_height;
+    ITextureBinder* m_binder;
 };
 
 #endif /* _WAYLANDGLESRENDERER_H_*/
index 66f9cd8..13470ba 100644 (file)
@@ -41,6 +41,7 @@ WaylandGLESRenderer::WaylandGLESRenderer(Scene* pScene)
 , m_pGraphicSystem(0)
 , m_width(0)
 , m_height(0)
+, m_binder(0)
 {
     LOG_DEBUG("WaylandGLESRenderer", "Creating Renderer");
 }
@@ -49,7 +50,7 @@ bool WaylandGLESRenderer::start(int width, int height, const char* displayname)
 {
     struct wl_display* nativeDisplayHandle = NULL;
     EGLDisplay eglDisplayhandle = NULL;
-    ITextureBinder* binder = NULL;
+    m_binder = NULL;
     m_width = width;
     m_height = height;
     // create Wayland windows, register as composite manager etc
@@ -90,17 +91,17 @@ bool WaylandGLESRenderer::start(int width, int height, const char* displayname)
     eglDisplayhandle = m_pGraphicSystem->getEGLDisplay();
 
 #ifdef WITH_FORCE_COPY
-    binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
 #else // WITH_FORCE_COPY
 #ifdef EGL_NATIVE_PIXMAP_KHR
-    binder = new WaylandEglImage(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new WaylandEglImage(eglDisplayhandle, nativeDisplayHandle);
 #else // EGL_NATIVE_PIXMAP_KHR
-    binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new WaylandCopyGLES(eglDisplayhandle, nativeDisplayHandle);
 #endif // EGL_NATIVE_PIXMAP_KHR
 #endif // WITH_FORCE_COPY
-    if ( binder && nativeDisplayHandle && eglDisplayhandle)
+    if (m_binder && nativeDisplayHandle && eglDisplayhandle)
     {
-        m_pGraphicSystem->setTextureBinder(binder);
+        m_pGraphicSystem->setTextureBinder(m_binder);
 
         if (!m_pWindowSystem->start())
         {
@@ -122,6 +123,10 @@ bool WaylandGLESRenderer::start(int width, int height, const char* displayname)
 void WaylandGLESRenderer::stop()
 {
     m_pWindowSystem->stop();
+    if(m_binder)
+    {
+        delete m_binder;
+    }
 }
 
 void WaylandGLESRenderer::doScreenShot(std::string fileToSave)
index 0ffd01c..b08fffa 100644 (file)
@@ -46,6 +46,7 @@ private:
     GLESGraphicsystem* m_pGraphicSystem;
     uint m_width;
     uint m_height;
+    ITextureBinder* m_binder;
 };
 
 #endif /* _X11GLESRENDERER_H_*/
index 27ccb32..5708c1f 100644 (file)
@@ -33,9 +33,11 @@ ShaderProgram* ShaderProgramGLES::createProgram(const std::string& vertName, con
     const char* pluginLookupPath = getenv("LM_PLUGIN_PATH");
     if  (pluginLookupPath != NULL ) 
     {
-        strcpy(defaultShaderDir,pluginLookupPath);
-    } else {
-        strcpy(defaultShaderDir,"/usr/lib/layermanager");
+        strncpy(defaultShaderDir, pluginLookupPath, sizeof(defaultShaderDir) - 1);
+    }
+    else
+    {
+        strncpy(defaultShaderDir,"/usr/lib/layermanager", sizeof(defaultShaderDir));
     }
     strcat(defaultShaderDir,"/renderer");
 
index e2c73cc..e2535ba 100644 (file)
@@ -31,6 +31,7 @@ X11GLESRenderer::X11GLESRenderer(Scene* pScene)
 , m_pGraphicSystem(0)
 , m_width(0)
 , m_height(0)
+, m_binder(NULL)
 {
     LOG_DEBUG("X11GLESRenderer", "Creating Renderer");
 }
@@ -39,7 +40,7 @@ bool X11GLESRenderer::start(int width, int height, const char* displayname)
 {
     Display* nativeDisplayHandle = NULL;
     EGLDisplay eglDisplayhandle = NULL;
-    ITextureBinder* binder = NULL;
+    m_binder = NULL;
     m_width = width;
     m_height = height;
     // create X11 windows, register as composite manager etc
@@ -61,17 +62,17 @@ bool X11GLESRenderer::start(int width, int height, const char* displayname)
     eglDisplayhandle = m_pGraphicSystem->getEGLDisplay();
 
 #ifdef WITH_FORCE_COPY
-    binder = new X11CopyGLES(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new X11CopyGLES(eglDisplayhandle, nativeDisplayHandle);
 #else // WITH_FORCE_COPY
 #ifdef EGL_NATIVE_PIXMAP_KHR
-    binder = new X11EglImage(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new X11EglImage(eglDisplayhandle, nativeDisplayHandle);
 #else // EGL_NATIVE_PIXMAP_KHR
-    binder = new X11CopyGLES(eglDisplayhandle, nativeDisplayHandle);
+    m_binder = new X11CopyGLES(eglDisplayhandle, nativeDisplayHandle);
 #endif // EGL_NATIVE_PIXMAP_KHR
 #endif // WITH_FORCE_COPY
-    if ( binder && nativeDisplayHandle && eglDisplayhandle)
+    if (m_binder && nativeDisplayHandle && eglDisplayhandle)
     {
-        m_pGraphicSystem->setTextureBinder(binder);
+        m_pGraphicSystem->setTextureBinder(m_binder);
 
         if (!m_pWindowSystem->start())
         {
@@ -93,6 +94,10 @@ bool X11GLESRenderer::start(int width, int height, const char* displayname)
 void X11GLESRenderer::stop()
 {
     m_pWindowSystem->stop();
+    if (m_binder)
+    {
+        delete m_binder;
+    }
 }
 
 void X11GLESRenderer::doScreenShot(std::string fileToSave)
index f71d5f1..c7bad92 100644 (file)
@@ -93,6 +93,7 @@ public:
     , frameCounter(0)
     , updateCounter(0)
     , drawCounter(0)
+    , m_nativeHandle(0)
     , m_pixformat(PIXELFORMAT_UNKNOWN)
     , m_layerId(INVALID_ID)
     , m_hasNativeContent(false)
@@ -104,7 +105,8 @@ public:
     , platform(NULL)
     , frameCounter(0)
     , updateCounter(0)
-    , drawCounter(0)   
+    , drawCounter(0)
+    , m_nativeHandle(0)
     , m_pixformat(PIXELFORMAT_UNKNOWN)
     , m_layerId(INVALID_ID)
     , m_hasNativeContent(false)
index d5f85a6..e287966 100644 (file)
@@ -51,6 +51,16 @@ Layermanager::~Layermanager()
     {
         delete m_pCommunicatorList;
     }
+
+    if (m_pSceneProviderList)
+    {
+        delete m_pSceneProviderList;
+    }
+
+    if (m_pApplicationReferenceMap)
+    {
+        delete m_pApplicationReferenceMap;
+    }
 }
 
 uint Layermanager::getLayerTypeCapabilities(const LayerType layertype) const
index 87a9cff..11c6c06 100644 (file)
@@ -93,6 +93,7 @@ T* getCreateFunction(string libname)
     if (!libraryHandle || dlopen_error)
     {
         LOG_ERROR("LayerManagerService", "dlopen failed: " << dlopen_error);
+        free(libraryHandle);
         return 0;
     }
 
@@ -119,6 +120,10 @@ T* getCreateFunction(string libname)
         LOG_ERROR("LayerManagerService", "Failed to load shared lib entry point: " << dlsym_error);
     }
 
+    // TODO: free these resources on shutdown
+    //dlclose(libraryHandle);
+    //free(libraryHandle);
+
     return createFunction;
 }
 
@@ -206,8 +211,8 @@ void loadScenePlugins(SceneProviderList& sceneProviderList, ICommandExecutor* ex
     for (uint dirIndex = 0; dirIndex < gScenePluginDirectoriesCount; ++dirIndex)
     {
         char directoryName[1024];
-        strcpy(directoryName,gPluginLookupPath);
-        strcat(directoryName,gScenePluginDirectories[dirIndex]);
+        strncpy(directoryName, gPluginLookupPath, sizeof(directoryName) - 1);
+        strncat(directoryName, gScenePluginDirectories[dirIndex], sizeof(directoryName) - 1 - strlen(directoryName));
         LOG_DEBUG("LayerManagerService", "Searching for SceneProviders in: " << directoryName);
         getSharedLibrariesFromDirectory(sharedLibraryNameList, directoryName);
     }
@@ -253,8 +258,8 @@ void loadCommunicatorPlugins(CommunicatorList& communicatorList, ICommandExecuto
     for (uint dirIndex = 0; dirIndex < gCommunicatorPluginDirectoriesCount; ++dirIndex)
     {
         char directoryName[1024];
-        strcpy(directoryName,gPluginLookupPath);
-        strcat(directoryName,gCommunicatorPluginDirectories[dirIndex]);
+        strncpy(directoryName, gPluginLookupPath, sizeof(directoryName) - strlen(directoryName));
+        strncat(directoryName, gCommunicatorPluginDirectories[dirIndex], sizeof(directoryName) -strlen(directoryName));
         LOG_DEBUG("LayerManagerService", "Searching for communicator in: " << directoryName);
         getSharedLibrariesFromDirectory(sharedLibraryNameList, directoryName);
     }
@@ -299,8 +304,8 @@ void loadRendererPlugins(RendererList& rendererList, IScene* pScene)
     for (uint dirIndex = 0; dirIndex < gRendererPluginDirectoriesCount; ++dirIndex)
     {
         char directoryName[1024];
-        strcpy(directoryName,gPluginLookupPath);
-        strcat(directoryName,gRendererPluginDirectories[dirIndex]);        
+        strncpy(directoryName, gPluginLookupPath, sizeof(directoryName) - 1);
+        strncat(directoryName, gRendererPluginDirectories[dirIndex], sizeof(directoryName) - 1 - strlen(directoryName));
         LOG_DEBUG("LayerManagerService", "Searching for renderer in: " << directoryName);
         getSharedLibrariesFromDirectory(sharedLibraryNameList, directoryName);
     }
index 37315ff..1129823 100644 (file)
@@ -86,11 +86,12 @@ ShaderUniform* ShaderUniform::createFromStringDescription(
     }
 
     // get element count
-    int count;
-    if ((iss >> count).fail())
+    unsigned int count = 0;
+    iss >> count;
+    if (iss.fail())
     {
         // failed to parse element count
-        LOG_ERROR("Shader Uniform","Fail to parse element count " << count);
+        LOG_ERROR("Shader Uniform","Fail to parse element count.");
         return NULL;
     }
 
@@ -109,8 +110,9 @@ ShaderUniform* ShaderUniform::createFromStringDescription(
     size_t numValuesExpected = count * m_vectorSizesOfDataTypes[type];
     for (size_t i = 0; i < numValuesExpected; i++)
     {
-        float value;
-        if ((iss >> value).fail())
+        float value = 0.0;
+        iss >> value;
+        if (iss.fail())
         {
             // failed to parse value
             LOG_ERROR("Shader Uniform","Fail to parse value " << value);