File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ LOG_MODULE_REGISTER(context, CONFIG_OCRE_LOG_LEVEL);
3030
3131struct ocre_context {
3232 pthread_mutex_t mutex ;
33- const char * working_directory ;
33+ char * working_directory ;
3434 struct container_node * containers ;
3535};
3636
@@ -98,7 +98,10 @@ struct ocre_context *ocre_context_create(const char *workdir)
9898
9999 /* Set working directory */
100100
101- context -> working_directory = workdir ;
101+ context -> working_directory = strdup (workdir );
102+ if (!context -> working_directory ) {
103+ goto error ;
104+ }
102105
103106 /* Initialize containers list */
104107
@@ -108,6 +111,7 @@ struct ocre_context *ocre_context_create(const char *workdir)
108111
109112error :
110113 free (context );
114+ free (context -> working_directory );
111115
112116 return NULL ;
113117};
@@ -163,6 +167,7 @@ int ocre_context_destroy(struct ocre_context *context)
163167 return -1 ;
164168 }
165169
170+ free (context -> working_directory );
166171 free (context );
167172
168173 return 0 ;
You can’t perform that action at this time.
0 commit comments