summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
Diffstat (limited to 'cppuhelper')
-rw-r--r--cppuhelper/source/findsofficepath.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/cppuhelper/source/findsofficepath.c b/cppuhelper/source/findsofficepath.c
index 1bd73684787f..903b91bde303 100644
--- a/cppuhelper/source/findsofficepath.c
+++ b/cppuhelper/source/findsofficepath.c
@@ -135,8 +135,10 @@ static char* platformSpecific()
env = getenv( PATHVARNAME );
if (env == NULL)
return NULL;
- str = (char*) malloc( strlen( env ) + 1 );
- strcpy( str, env );
+
+ str = strdup( env );
+ if (str == NULL)
+ return NULL;
/* get the tokens separated by ':' */
dir = strtok( str, PATHSEPARATOR );
@@ -145,6 +147,12 @@ static char* platformSpecific()
{
/* construct soffice file path */
file = (char*) malloc( strlen( dir ) + strlen( APPENDIX ) + 1 );
+ if (file == NULL)
+ {
+ free(str);
+ return NULL;
+ }
+
strcpy( file, dir );
strcat( file, APPENDIX );