From 05bd9ed45d7a985ba7a53d0c122d6dbcd6cb2652 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Sat, 24 Feb 2018 20:43:12 +0000 Subject: [PATCH] forcepoint #8 ensure ColumnDef lifetime MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Idb0c7b1530dc57f4d7c14751f1b76caecc3b03a6 Reviewed-on: https://gerrit.libreoffice.org/50288 Reviewed-by: Caolán McNamara Tested-by: Caolán McNamara --- hwpfilter/source/hinfo.cxx | 11 ++++++----- hwpfilter/source/hinfo.h | 2 +- hwpfilter/source/hpara.cxx | 4 ++-- hwpfilter/source/hwpfile.cxx | 6 +++--- hwpfilter/source/hwpfile.h | 5 ++--- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/hwpfilter/source/hinfo.cxx b/hwpfilter/source/hinfo.cxx index 9cf5907e9950..d477d845c3b1 100644 --- a/hwpfilter/source/hinfo.cxx +++ b/hwpfilter/source/hinfo.cxx @@ -201,6 +201,7 @@ ParaShape::ParaShape() , pspacing_next(0) , condense(0) , arrange_type(0) + , xColdef(new ColumnDef) , shade(0) , outline(0) , outline_continue(0) @@ -240,17 +241,17 @@ void ParaShape::Read(HWPFile & hwpf) return; tab.position = tmp16; } - hwpf.Read1b(coldef.ncols); - hwpf.Read1b(coldef.separator); + hwpf.Read1b(xColdef->ncols); + hwpf.Read1b(xColdef->separator); if (!hwpf.Read2b(tmp16)) return; - coldef.spacing = tmp16; + xColdef->spacing = tmp16; if (!hwpf.Read2b(tmp16)) return; - coldef.columnlen = tmp16; + xColdef->columnlen = tmp16; if (!hwpf.Read2b(tmp16)) return; - coldef.columnlen0 = tmp16; + xColdef->columnlen0 = tmp16; hwpf.Read1b(shade); hwpf.Read1b(outline); hwpf.Read1b(outline_continue); diff --git a/hwpfilter/source/hinfo.h b/hwpfilter/source/hinfo.h index 049082e39e28..2cdaba65b2da 100644 --- a/hwpfilter/source/hinfo.h +++ b/hwpfilter/source/hinfo.h @@ -292,7 +292,7 @@ struct ParaShape unsigned char condense; unsigned char arrange_type; TabSet tabs[MAXTABS]; - ColumnDef coldef; + std::shared_ptr xColdef; unsigned char shade; unsigned char outline; unsigned char outline_continue; diff --git a/hwpfilter/source/hpara.cxx b/hwpfilter/source/hpara.cxx index ebade2180463..08486c827d08 100644 --- a/hwpfilter/source/hpara.cxx +++ b/hwpfilter/source/hpara.cxx @@ -124,8 +124,8 @@ bool HWPPara::Read(HWPFile & hwpf, unsigned char flag) } if (nch && !reuse_shape){ - if( pshape->coldef.ncols > 1 ) { - hwpf.SetColumnDef(&(pshape->coldef)); + if( pshape->xColdef->ncols > 1 ) { + hwpf.SetColumnDef(pshape->xColdef); } } diff --git a/hwpfilter/source/hwpfile.cxx b/hwpfilter/source/hwpfile.cxx index f7b78fdf704c..552233dd853d 100644 --- a/hwpfilter/source/hwpfile.cxx +++ b/hwpfilter/source/hwpfile.cxx @@ -412,7 +412,7 @@ void HWPFile::TagsRead() ColumnDef *HWPFile::GetColumnDef(int num) { if (static_cast(num) < columnlist.size()) - return columnlist[num]->coldef; + return columnlist[num]->xColdef.get(); else return nullptr; } @@ -569,12 +569,12 @@ void HWPFile::AddColumnInfo() setMaxSettedPage(); } -void HWPFile::SetColumnDef(ColumnDef *coldef) +void HWPFile::SetColumnDef(const std::shared_ptr& rColdef) { ColumnInfo *cinfo = columnlist.back().get(); if( cinfo->bIsSet ) return; - cinfo->coldef = coldef; + cinfo->xColdef = rColdef; cinfo->bIsSet = true; } diff --git a/hwpfilter/source/hwpfile.h b/hwpfilter/source/hwpfile.h index f39681ffad84..442b442e0514 100644 --- a/hwpfilter/source/hwpfile.h +++ b/hwpfilter/source/hwpfile.h @@ -72,11 +72,10 @@ class HStream; struct ColumnInfo{ int start_page; bool bIsSet; - ColumnDef *coldef; + std::shared_ptr xColdef; explicit ColumnInfo(int num){ start_page = num; bIsSet = false; - coldef = nullptr; } }; @@ -211,7 +210,7 @@ class DLLEXPORT HWPFile void AddBox(FBox *); void AddPage(){ m_nCurrentPage++;} void AddColumnInfo(); - void SetColumnDef(ColumnDef *coldef); + void SetColumnDef(std::shared_ptr const &); void AddParaShape(std::shared_ptr const &); void AddCharShape(std::shared_ptr const &); void AddFBoxStyle(FBoxStyle *);