Project

General

Profile

Actions

Bug #3678

closed

Face::put(const Data&) undefined behavior

Added by Junxiao Shi almost 8 years ago. Updated over 7 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Base
Target version:
Start date:
07/19/2016
Due date:
% Done:

100%

Estimated time:
3.00 h

Description

Face::put(const Data&) recommends its data parameter to be managed by a shared_ptr to avoid copying, but does not require that.

This code checks whether a shared_ptr is available:

  try {
    dataPtr = data.shared_from_this();
  }
  catch (const bad_weak_ptr& e) {

However, until C++17, std::enable_shared_from_this::shared_from_this is undefined behavior if the Data is not previously managed by a shared_ptr.
Therefore, this checking code is unsafe in C++11 or C++14.

Actions

Also available in: Atom PDF