From 7b750d30e23312c7c9924be13b81c0b8c9296c99 Mon Sep 17 00:00:00 2001 From: eddyg Date: Tue, 2 Oct 2007 03:30:45 +0000 Subject: [PATCH] When duplicating the x264 options keep a pointer to the start of the options so that we can free them. Also check that the memory allocation actually succeeded. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@998 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- libhb/encx264.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libhb/encx264.c b/libhb/encx264.c index 0de2e9f3b..7c2d55480 100644 --- a/libhb/encx264.c +++ b/libhb/encx264.c @@ -99,8 +99,11 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) if( job->x264opts != NULL && *job->x264opts != '\0' ) { - char *x264opts = strdup(job->x264opts); - while( *x264opts ) + char *x264opts, *x264opts_start; + + x264opts = x264opts_start = strdup(job->x264opts); + + while( x264opts_start && *x264opts ) { char *name = x264opts; char *value; @@ -161,7 +164,7 @@ int encx264Init( hb_work_object_t * w, hb_job_t * job ) if( ret == X264_PARAM_BAD_VALUE ) hb_log( "x264 options: Bad argument %s=%s", name, value ? value : "(null)" ); } - free(x264opts); + free(x264opts_start); } -- 2.40.0