summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-03-10 10:35:43 +0000
committerMiklos Vajna <vmiklos@collabora.co.uk>2017-03-10 12:47:59 +0000
commitdcda65506e0a5c8526cfd7bbd0e3d4721507871f (patch)
tree9bee139bba03a3a08e11a0ec780fd90d5da61246
parenttdf#106283: Registry settings are not read properly on Windows (diff)
downloadcore-dcda65506e0a5c8526cfd7bbd0e3d4721507871f.tar.gz
core-dcda65506e0a5c8526cfd7bbd0e3d4721507871f.zip
ofz#798 oom
(cherry picked from commit 75f118da50b217956ee7a735e921524d0c2935ff) Change-Id: I6fa8dd999af7e00d6236a1ead5f8bb519f2d128d Reviewed-on: https://gerrit.libreoffice.org/35038 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r--hwpfilter/source/hbox.cxx5
-rw-r--r--hwpfilter/source/hbox.h91
-rw-r--r--hwpfilter/source/hwpread.cxx10
3 files changed, 49 insertions, 57 deletions
diff --git a/hwpfilter/source/hbox.cxx b/hwpfilter/source/hbox.cxx
index da9e206440f3..04d5497ce1f3 100644
--- a/hwpfilter/source/hbox.cxx
+++ b/hwpfilter/source/hbox.cxx
@@ -77,18 +77,13 @@ hchar_string HBox::GetString()
// skip block
SkipData::SkipData(hchar hch)
: HBox(hch)
- , data_block_len(0)
- , dummy(0)
- , data_block(nullptr)
{
}
SkipData::~SkipData()
{
- delete[]data_block;
}
-
// FieldCode [5]
FieldCode::FieldCode()
: HBox(CH_FIELD)
diff --git a/hwpfilter/source/hbox.h b/hwpfilter/source/hbox.h
index 3832c7617174..a9aa2b452892 100644
--- a/hwpfilter/source/hbox.h
+++ b/hwpfilter/source/hbox.h
@@ -1,21 +1,21 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+*
+* This file incorporates work covered by the following license notice:
+*
+* Licensed to the Apache Software Foundation (ASF) under one or more
+* contributor license agreements. See the NOTICE file distributed
+* with this work for additional information regarding copyright
+* ownership. The ASF licenses this file to you under the Apache
+* License, Version 2.0 (the "License"); you may not use this file
+* except in compliance with the License. You may obtain a copy of
+* the License at http://www.apache.org/licenses/LICENSE-2.0 .
+*/
#ifndef INCLUDED_HWPFILTER_SOURCE_HBOX_H
#define INCLUDED_HWPFILTER_SOURCE_HBOX_H
@@ -32,53 +32,50 @@
#include "hpara.h"
/**
- * The HBox class is the base class for all date classes in hwp document.
- * For example, there are special character, table, image, etc.
- * It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32.
- *
- * @short Base class for characters
- */
+* The HBox class is the base class for all date classes in hwp document.
+* For example, there are special character, table, image, etc.
+* It has one character. The ascii code value of special characters are smaller than 32. General character is greater than 32.
+*
+* @short Base class for characters
+*/
struct HBox
{
- public:
- hchar hh;
+public:
+ hchar hh;
/**
- * Construct a HBox object with parameter hch.
- * @param hch 16bit character being able to have Korean character.
- */
- explicit HBox( hchar hch );
- virtual ~HBox();
+* Construct a HBox object with parameter hch.
+* @param hch 16bit character being able to have Korean character.
+*/
+ explicit HBox( hchar hch );
+ virtual ~HBox();
/**
- * @returns The Size of HBox object
- */
- int WSize();
+* @returns The Size of HBox object
+*/
+ int WSize();
/**
- * Read properties from HIODevice object like stream, file, memory.
- *
- * @param hwpf HWPFile Object having all information for a hwp file.
- * @returns True if reading from stream is successful.
- */
- virtual bool Read(HWPFile &hwpf);
+* Read properties from HIODevice object like stream, file, memory.
+*
+* @param hwpf HWPFile Object having all information for a hwp file.
+* @returns True if reading from stream is successful.
+*/
+ virtual bool Read(HWPFile &hwpf);
- virtual hchar_string GetString();
- private:
- static int boxCount;
+ virtual hchar_string GetString();
+private:
+ static int boxCount;
};
/**
- * @short Class for saving data to be skipped.
- */
+* @short Class for skipping data.
+*/
struct SkipData: public HBox
{
- uint data_block_len;
- hchar dummy;
- char *data_block;
-
explicit SkipData(hchar);
virtual ~SkipData() override;
virtual bool Read(HWPFile &hwpf) override;
};
+
struct DateCode;
struct FieldCode : public HBox
{
diff --git a/hwpfilter/source/hwpread.cxx b/hwpfilter/source/hwpread.cxx
index 377c13ee203c..abeaca660d53 100644
--- a/hwpfilter/source/hwpread.cxx
+++ b/hwpfilter/source/hwpread.cxx
@@ -45,19 +45,19 @@ bool HBox::Read(HWPFile & )
bool SkipData::Read(HWPFile & hwpf)
{
+ uint data_block_len;
hwpf.Read4b(&data_block_len, 1);
+
+ hchar dummy;
hwpf.Read2b(&dummy, 1);
if (!(IS_SP_SKIP_BLOCK(hh) && (hh == dummy))){
return hwpf.SetState(HWP_InvalidFileFormat);
- }
-
- data_block = new char[data_block_len];
+ }
- return hwpf.Read1b(data_block, data_block_len);
+ return hwpf.SkipBlock(data_block_len);
}
-
// Field code(5)
bool FieldCode::Read(HWPFile & hwpf)
{