xdiff/xprepare: initialise xdlclassifier_t cf in xdl_prepare_env()
PATCH 1/1 xdiff/xprepare: initialise xdlclassifier_t cf in xdl_prepare_env()
Ensure that the xdl_free_classifier() call on xdlclassifier_t cf is safe even if xdl_init_classifier() isn't called. This may occur in the case where diff is run with --histogram and a call to, say, xdl_prepare_ctx() fails.
---
This should go into 'rc/histogram-diff' in 'next'.
xdiff/xprepare.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
xdiff/xprepare.c +3 -0
@@ -239,6 +239,9 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,long enl1, enl2, sample;xdlclassifier_t cf; + cf.rchash =NULL ; + cf.ncha.head =NULL ; +/* * For histogram diff, we can afford a smaller sample size and * thus a poorer estimate of the number of lines, as the hash
Signature · 1 line
1.7.6.1.706.gaa5cf
Quoted 6 lines · Tay Ray Chuan
Ensure that the
xdl_free_classifier()call onxdlclassifier_tcf is safe even ifxdl_init_classifier()isn't called. This may occur in the case where diff is run with --histogram and a call to, say,xdl_prepare_ctx()fails.Signed-off-by Tay Ray Chuan <[email protected]>
Thanks. Did you find this by code inspection?
xdiff/xprepare.c int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, · line 243
Quoted 13 lines
xdiff/xprepare.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)xdiff/xprepare.c +2
-0@@ -239,6 +239,9 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,long enl1, enl2, sample;xdlclassifier_t cf; + cf.rchash =NULL ; + cf.ncha.head =NULL ;
Would it be more appropriate to use memcpy(&cf, 0, sizeof(cf)) instead, so that we wouldn't have to worry about a similar breakage when a new field is added to "struct xdlclassifier" later?
Quoted 22 lines · Junio C Hamano
Quoted 6 lines · Tay Ray Chuan
Ensure that the
xdl_free_classifier()call onxdlclassifier_tcf is safe even ifxdl_init_classifier()isn't called. This may occur in the case where diff is run with --histogram and a call to, say,xdl_prepare_ctx()fails.Signed-off-by Tay Ray Chuan <[email protected]>Thanks. Did you find this by code inspection?
Quoted 11 lines
xdiff/xprepare.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)xdiff/xprepare.c +0
-0@@ -239,6 +239,9 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,long enl1, enl2, sample;xdlclassifier_t cf;
Quoted 4 lines
xdiff/xprepare.c int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, · line 243
Quoted 2 lines
xdiff/xprepare.c +2
-0+ cf.rchash =NULL ; + cf.ncha.head =NULL ;Would it be more appropriate to use
memcpy(&cf, 0, sizeof(cf))instead, so
Oops, I meant memset(), obviously.
Quoted 2 lines
that we wouldn't have to worry about a similar breakage when a new field is added to "struct xdlclassifier" later?
PATCH 1/1 xdiff/xprepare: initialise xdlclassifier_t cf in xdl_prepare_env()
Ensure that the xdl_free_classifier() call on xdlclassifier_t cf is safe even if xdl_init_classifier() isn't called, which is the case when diff is run with --histogram.
---
Quoted 10 lines · Junio C Hamano
Quoted 6 lines · Tay Ray Chuan
Ensure that the
xdl_free_classifier()call onxdlclassifier_tcf is safe even ifxdl_init_classifier()isn't called. This may occur in the case where diff is run with --histogram and a call to, say,xdl_prepare_ctx()fails.Signed-off-by Tay Ray Chuan <[email protected]>Thanks. Did you find this by code inspection?
If by "code inspection" you meant eye-balling, then yes. :)
Quoted 6 lines · Junio C Hamano
Junio C Hamano <[email protected]> writes:
[snip]Quoted 4 lines
Quoted 4 lines
(quoted diff) +0
-0@@ -239,6 +239,9 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, long enl1, enl2, sample; xdlclassifier_t cf;
Quoted 6 lines
Quoted 4 lines
Review int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp, · line 243
Quoted 2 lines
(quoted diff) +2
-0+ cf.rchash = NULL; + cf.ncha.head = NULL;Would it be more appropriate to use
memcpy(&cf, 0, sizeof(cf))instead, soOops, I meant
memset(), obviously.
Right, thanks.
--- xdiff/xprepare.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
xdiff/xprepare.c +2 -0
@@ -239,6 +239,8 @@ int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,long enl1, enl2, sample;xdlclassifier_t cf; +memset (&cf,0 ,sizeof (cf)); +/* * For histogram diff, we can afford a smaller sample size and * thus a poorer estimate of the number of lines, as the hash
Signature · 1 line
1.7.6.1.706.gaa5cf