diff --git a/containers/core/containers_writer_utils.c b/containers/core/containers_writer_utils.c index 7e24ef3..583ad93 100644 --- a/containers/core/containers_writer_utils.c +++ b/containers/core/containers_writer_utils.c @@ -32,6 +32,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "containers/core/containers_private.h" #include "containers/core/containers_utils.h" #include "containers/core/containers_writer_utils.h" +#include "vcos.h" #include @@ -77,7 +78,7 @@ VC_CONTAINER_STATUS_T vc_container_writer_extraio_create_temp(VC_CONTAINER_T *co VC_CONTAINER_STATUS_T vc_container_writer_extraio_delete(VC_CONTAINER_T *context, VC_CONTAINER_WRITER_EXTRAIO_T *extraio) { VC_CONTAINER_STATUS_T status; - char *uri = extraio->temp ? strdup(extraio->io->uri) : 0; + char *uri = extraio->temp ? vcos_strdup(extraio->io->uri) : 0; while(extraio->refcount) vc_container_writer_extraio_disable(context, extraio); status = vc_container_io_close( extraio->io ); diff --git a/containers/test/test.c b/containers/test/test.c index 73cbecd..f6a5b08 100644 --- a/containers/test/test.c +++ b/containers/test/test.c @@ -98,12 +98,12 @@ int main(int argc, char **argv) if (psz_out) { - psz_dump = strdup(psz_out); + psz_dump = vcos_strdup(psz_out); } else { psz_dump = strrchr(psz_in, '\\'); if(psz_dump) psz_dump++; if(!psz_dump) {psz_dump = strrchr(psz_in, '/'); if(psz_dump) psz_dump++;} - if(!psz_dump) psz_dump = strdup(psz_in); - else psz_dump = strdup(psz_dump); + if(!psz_dump) psz_dump = vcos_strdup(psz_in); + else psz_dump = vcos_strdup(psz_dump); psz_dump[strlen(psz_dump)-1] = '1'; } dump_file = fopen(psz_dump, "wb"); diff --git a/interface/vcos/pthreads/vcos_platform.h b/interface/vcos/pthreads/vcos_platform.h index d324508..59d9aff 100644 --- a/interface/vcos/pthreads/vcos_platform.h +++ b/interface/vcos/pthreads/vcos_platform.h @@ -815,7 +815,13 @@ VCOS_INLINE_DECL void _vcos_thread_sem_post(VCOS_THREAD_T *); VCOS_STATIC_INLINE char *vcos_strdup(const char *str) { - return strdup(str); + size_t len = strlen(str) + 1; + void *p = malloc(len); + + if (p == NULL) + return NULL; + + return (char *)memcpy(p, str, len); } typedef void (*VCOS_ISR_HANDLER_T)(VCOS_UNSIGNED vecnum);