summaryrefslogtreecommitdiff
path: root/cppuhelper
diff options
context:
space:
mode:
authorArnaud Versini <arnaud.versini@gmail.com>2014-05-09 10:38:04 +0200
committerStephan Bergmann <sbergman@redhat.com>2014-05-20 09:47:54 +0200
commitcd11bc699ac50af4f560ed5f2e5e7903de0898b8 (patch)
tree2b5683460af2b171212bb766deb4cb7ee5858d4e /cppuhelper
parent498c314861f0913a5b31ee29efc38aad12c3a781 (diff)
C string usage improvment
Change-Id: I5c59f0d2d1b911ffa1ee251e0f1355d137616493 Signed-off-by: Stephan Bergmann <sbergman@redhat.com>
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 );