Fix crash when feature contains invalid UTF-8 data (#2693)
This commit is contained in:
@@ -18,10 +18,9 @@ std::unique_ptr<style::Layer> CircleLayerFactory::createLayer(const std::string&
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::CircleLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> CircleLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
std::unique_ptr<Layout> CircleLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) {
|
||||
return std::unique_ptr<Layout>(new (std::nothrow)
|
||||
CircleLayout(parameters.bucketParameters, group, std::move(layer)));
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ std::unique_ptr<style::Layer> FillExtrusionLayerFactory::createLayer(
|
||||
std::unique_ptr<Layout> FillExtrusionLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) {
|
||||
using namespace style;
|
||||
using LayoutType = PatternLayout<FillExtrusionBucket, FillExtrusionLayerProperties, FillExtrusionPattern>;
|
||||
return std::unique_ptr<Layout>(new (std::nothrow)
|
||||
|
||||
@@ -17,10 +17,9 @@ std::unique_ptr<style::Layer> FillLayerFactory::createLayer(const std::string& i
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::FillLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> FillLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
std::unique_ptr<Layout> FillLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> layer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) {
|
||||
using namespace style;
|
||||
using LayoutTypeUnsorted = PatternLayout<FillBucket, FillLayerProperties, FillPattern, FillLayoutProperties>;
|
||||
using LayoutTypeSorted =
|
||||
|
||||
@@ -33,7 +33,7 @@ std::unique_ptr<Bucket> LayerFactory::createBucket(const BucketParameters&,
|
||||
|
||||
std::unique_ptr<Layout> LayerFactory::createLayout(const LayoutParameters&,
|
||||
std::unique_ptr<GeometryTileLayer>,
|
||||
const std::vector<Immutable<style::LayerProperties>>&) noexcept {
|
||||
const std::vector<Immutable<style::LayerProperties>>&) {
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -17,10 +17,9 @@ std::unique_ptr<style::Layer> SymbolLayerFactory::createLayer(const std::string&
|
||||
return std::unique_ptr<style::Layer>(source ? new (std::nothrow) style::SymbolLayer(id, *source) : nullptr);
|
||||
}
|
||||
|
||||
std::unique_ptr<Layout> SymbolLayerFactory::createLayout(
|
||||
const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) noexcept {
|
||||
std::unique_ptr<Layout> SymbolLayerFactory::createLayout(const LayoutParameters& parameters,
|
||||
std::unique_ptr<GeometryTileLayer> tileLayer,
|
||||
const std::vector<Immutable<style::LayerProperties>>& group) {
|
||||
return std::unique_ptr<Layout>(
|
||||
new (std::nothrow) SymbolLayout(parameters.bucketParameters, group, std::move(tileLayer), parameters));
|
||||
}
|
||||
|
||||
@@ -156,11 +156,19 @@ SymbolLayout::SymbolLayout(const BucketParameters& parameters,
|
||||
} else if (textTransform == TextTransformType::Lowercase) {
|
||||
u8string = platform::lowercase(u8string);
|
||||
}
|
||||
|
||||
ft.formattedText->addTextSection(applyArabicShaping(util::convertUTF8ToUTF16(u8string)),
|
||||
section.fontScale ? *section.fontScale : 1.0,
|
||||
section.fontStack ? *section.fontStack : baseFontStack,
|
||||
section.textColor);
|
||||
try {
|
||||
ft.formattedText->addTextSection(applyArabicShaping(util::convertUTF8ToUTF16(u8string)),
|
||||
section.fontScale ? *section.fontScale : 1.0,
|
||||
section.fontStack ? *section.fontStack : baseFontStack,
|
||||
section.textColor);
|
||||
} catch (...) {
|
||||
mbgl::Log::Error(
|
||||
mbgl::Event::ParseTile,
|
||||
"Encountered section with invalid UTF-8 in tile, source: " + sourceLayer->getName() +
|
||||
" z: " + std::to_string(canonicalID.z) + " x: " + std::to_string(canonicalID.x) +
|
||||
" y: " + std::to_string(canonicalID.y));
|
||||
continue; // skip section
|
||||
}
|
||||
} else {
|
||||
layoutParameters.imageDependencies.emplace(section.image->id(), ImageType::Icon);
|
||||
ft.formattedText->addImageSection(section.image->id());
|
||||
|
||||
Reference in New Issue
Block a user