From 9cfeb6ecfaaee07d17ce9313946518ca6006bc8e Mon Sep 17 00:00:00 2001 From: Basavapatna Dattaguru Date: Tue, 15 Feb 2011 21:54:48 -0800 Subject: [PATCH] VideoEditor:Issue ID: 3431967 Fixes memory leak in getProperties Updated with Review comments Change-Id: Ie4e8edaee1c76f18d0526b5eae9f9a128e0a3c17 --- .../mediaeditor/VideoEditorPropertiesMain.cpp | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp index 014cd95a88121..73a7c9c8a2729 100755 --- a/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp +++ b/media/jni/mediaeditor/VideoEditorPropertiesMain.cpp @@ -122,12 +122,26 @@ jobject videoEditProp_getProperties( &gotten, pEnv, file, NULL, M4OSA_NULL); result = M4OSA_fileReadOpen(&context, (M4OSA_Void*)pFile, M4OSA_kFileRead); + + if(M4NO_ERROR != result) { + // Free the file path. + videoEditOsal_free(pFile); + pFile = M4OSA_NULL; + } + videoEditJava_checkAndThrowIllegalArgumentException(&gotten, pEnv, (M4NO_ERROR != result), "file not found"); - if(M4NO_ERROR != result) - return(properties); - result = M4OSA_fileReadClose(context); - context = M4OSA_NULL; + + // Close the file and free the file context + if (context != NULL) { + result = M4OSA_fileReadClose(context); + context = M4OSA_NULL; + } + + // Return if Error + if (M4NO_ERROR != result) { + return (properties); // NULL + } // Check if the file path is valid. if (gotten)