Skip to content

Commit

Permalink
Merge branch 'master' into coverity_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
c-lipka committed Sep 12, 2018
2 parents 0b828e1 + 8fc5463 commit d359466
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 89 deletions.
11 changes: 11 additions & 0 deletions changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ Changed Behaviour
by directives (stuff that begins with `#`).
- UV mapping of cylinder, cone and lemon primitives has been disabled again
for now, due to their orientation being poorly defined.
- An age-old bug in the inbuilt `f_enneper` isosurface function has been
fixed; the function now results in the originally intended shape.

New Features
------------
Expand Down Expand Up @@ -99,6 +101,15 @@ Reported via the Newsgroups:
Trying to `#declare Foo[A][B]=...` with `Foo` being an array of arrays and
`Foo[A]` not yet initialized causes a hard crash instead of a parse error.

Reported by Coverity static code analysis:

- CID 986462,986463 (Wrapper object use after free)
- CID 967358-967362 (Uninitialized scalar variable)
- CID 1372542-1372544 (Result is not floating-point)
- CID 1372618 (Uninitialized scalar variable)
- CID 1372629 (Uninitialized pointer read)
- CID 1372630-1372632 (Uninitialized scalar variable)

Miscellaneous:

- Fix `interior_texture` for text objects (as mentioned in GitHub issue #65)
Expand Down
7 changes: 6 additions & 1 deletion distribution/include/functions.inc
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,12 @@
// 2. y scale (inverse)
// 3. z scale (inverse)

#declare f_enneper = function { internal(18) }
#if (Functions_Inc_Temp < 3.8)
#declare deprecated once "f_enneper was broken prior to v3.8; results will most likely differ."
f_enneper = function { internal(18) }
#else
#declare f_enneper = function { internal(18) }
#end
// Parameters: x, y, z
// One extra parameter required:
// 1. Field strength
Expand Down
107 changes: 107 additions & 0 deletions revision.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,113 @@ Notes:
POV-Ray v3.8.0-???
------------------------------------------------------------------------------

Commit 915abb22 on 2018-09-12 by Christoph Lipka

Fix uninitialized variables in photons code discovered by static code
analysis (CID 1372618, CID 1372630-1372632).
Also placate static code analysis about a few others in user function
VM code (CID 967358-967362).

Commit 65bd3196 on 2018-09-12 by Christoph Lipka

Fix bug in OpenEXR file handling code found by static code analysis
(CID 986462 and 986463).

Commit 7de830ce on 2018-09-12 by Christoph Lipka

Eliminate C-style memory allocation in parametric.

Commit 7fa6bb53 on 2018-09-12 by Christoph Lipka

Refactor flagging of opaque objects during parser post-processing.

Commit 6fdadbde on 2018-09-12 by Christoph Lipka

[windows] Fix error in recent commit 917a8763 that broke the build.

Commit 24700edb on 2018-09-12 by Christoph Lipka

Eliminate C-style memory allocation in polygon.

Commit 917a8763 on 2018-09-12 by Christoph Lipka

Get rid of C-style `NULL` throughout the code in favour of the less
ambiguous C++11-style `nullptr`.

Commit 72cf1a73 on 2018-09-12 by Christoph Lipka

Replace more magic constants in POVMS.

Commit aa0b48d7 on 2018-09-12 by Christoph Lipka

Clean up use of boolean values in POVMS.

Commit 49873bf9 on 2018-09-12 by Christoph Lipka

Improve code clarity with regards to POVMS return values, fixing a few
bugs along the way.

Commit dfda62b7 on 2018-09-12 by Christoph Lipka

Minor update to stack size configuration.

Commit 72862c76 on 2018-09-12 by Christoph Lipka

Minor code simplification in quadrics code.

Commit 7bde9196 on 2018-09-12 by Christoph Lipka

Update various comments and a few text strings.

Commit 344ed893 on 2018-09-11 by Christoph Lipka

Update to `.gitattribute`; most notably, prevent auto-merging of
`source/base/version.h`.

Commit 8a43226e on 2018-09-11 by Christoph Lipka

Minor update to `source/base/build.h` and related docs.

Commit 96489d42 on 2018-09-09 by Christoph Lipka

[unix] Make `.configure` script `COMPILED_BY` parameter optional,
defaulting to login name.

Commit 63580949 on 2018-09-09 by Christoph Lipka

Fix bug introduced with commit 1d120c90.

Commit 0984776b on 2018-09-09 by Christoph Lipka

Update git pre-commit hook. Please copy `tools/git/hooks/pre-commit`
to `.git/hooks/`.

Commit 2843d762 on 2018-09-08 by Christoph Lipka

Fix blatant coding error in POVMS UCS2 string handling.

Commit 264fa229 on 2018-09-07 by Christoph Lipka

Fix clang build error introduced with previous commit, and silence a
few more clang warnings.

Commit 1d120c90 on 2018-09-07 by Christoph Lipka

Silence some clang warnings.

Commit f09a7b4f on 2018-09-02 by Christoph Lipka

Disable new UV mappings of cylinder, cone and lemon primitives for now.

Commit d20c6d42 on 2018-08-27 by Christoph Lipka

Improve `#breakpoint` debugging aid.
Also update changelog.

------------------------------------------------------------------------------
POV-Ray v3.8.0-alpha.9811560
------------------------------------------------------------------------------

Commit c42e14e7 on 2018-08-27 by Christoph Lipka

Fix hard crash in `#declare Foo[A][B]=...` if `Foo` is an array of
Expand Down
3 changes: 0 additions & 3 deletions source/base/image/openexr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ class POV_EXR_OStream : public Imf::OStream
POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toASCIIString(pov_stream.Name()).c_str()), os(pov_stream) { }
virtual ~POV_EXR_OStream() { }

const char *fileName() const { return UCS2toASCIIString(os.Name()).c_str(); }

void write(const char *c, int n)
{
if(os.write(c, n) == false)
Expand Down Expand Up @@ -130,7 +128,6 @@ class POV_EXR_IStream : public Imf::IStream

virtual ~POV_EXR_IStream() { }

const char *fileName(void) const { return UCS2toASCIIString(is.Name()).c_str(); }
void clear(void) { is.clearstate(); }

bool read(char *c, int n)
Expand Down
10 changes: 8 additions & 2 deletions source/core/lighting/photons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,13 @@ void PhotonTrace::ComputeLightedTexture(MathColour& LightCol, ColourChannel&, co
doDiffuse = 0;
threadData->passThruPrev = true;
}
// else die
else
{
// die
doReflection = 0;
doRefraction = 0;
doDiffuse = 0;
}
}
else
{
Expand Down Expand Up @@ -571,7 +577,7 @@ void PhotonTrace::ComputeLightedTexture(MathColour& LightCol, ColourChannel&, co
}
#endif // PT_AMPLIFY_BUG

ColourChannel dummyTransm;
ColourChannel dummyTransm = 0.0; // Shouldn't matter, but placates static code analysis.
TraceRay(NRay, CurLightCol, dummyTransm, (float)New_Weight, true);

#ifndef PT_AMPLIFY_BUG
Expand Down
6 changes: 6 additions & 0 deletions source/core/scene/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,12 @@ bool ObjectBase::Intersect_BBox(BBoxDirection variant, const BBoxVector3d& origi
return false; // unreachable
}

bool ObjectBase::IsOpaque() const
{
return Test_Opacity(Texture) &&
((Interior_Texture == nullptr) || Test_Opacity(Interior_Texture));
}

void ContainedByBox::ComputeBBox(BoundingBox& rBbox) const
{
rBbox.lowerLeft = BBoxVector3d(corner1);
Expand Down
14 changes: 14 additions & 0 deletions source/core/scene/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,20 @@ class ObjectBase
///
virtual void DispatchShutdownMessages(GenericMessenger& messenger) {};

/// Test texture for opacity.
///
/// This method will be called by the parser as part of object post-processing,
/// to test whether the object's material is guaranteed to be fully opaque.
///
/// The default implementation reports the object as opaque if if has a texture that is
/// guaranteed to be opaque (as determined by @ref Test_Opacity()), and it has either no
/// explicit interior texture or that texture is also guaranteed to be opaque.
///
/// Primitives with innate textures (such as blob or mesh) must override this method, and
/// return false if any of their innate textures is potentially non-opaque.
///
virtual bool IsOpaque() const;

protected:
explicit ObjectBase(const ObjectBase&) { }
};
Expand Down
29 changes: 11 additions & 18 deletions source/core/shape/blob.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,30 +2638,23 @@ int Blob::Make_Blob(DBL threshold, Blob_List_Struct *BlobList, int npoints, Trac
*
******************************************************************************/

void Blob::Test_Blob_Opacity()
bool Blob::IsOpaque() const
{
/* Initialize opacity flag to the opacity of the object's texture. */

if ((Texture == nullptr) || (Test_Opacity(Texture)))
{
Set_Flag(this, OPAQUE_FLAG);
}

if (Test_Flag(this, MULTITEXTURE_FLAG))
{
for (vector<TEXTURE*>::iterator i = Element_Texture.begin(); i != Element_Texture.end(); ++i)
for (auto&& elementTexture : Element_Texture)
{
if (*i != nullptr)
{
/* If component's texture isn't opaque the blob is neither. */

if (!Test_Opacity(*i))
{
Clear_Flag(this, OPAQUE_FLAG);
}
}
// If component's texture isn't opaque the blob is neither.
if ((elementTexture != nullptr) && !Test_Opacity(elementTexture))
return false;
}
}

// Otherwise it's a question of whether the common texture is opaque or not.
// TODO FIXME - other objects report as non-opaque if Texture == nullptr.
// TODO FIXME - other objects report as non-opaque if Interior_Texture present and non-opaque.
// What we probably really want here is `return ObjectBase::IsOpaque()`.
return (Texture == nullptr) || Test_Opacity(Texture);
}


Expand Down
3 changes: 1 addition & 2 deletions source/core/shape/blob.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,14 @@ class Blob : public ObjectBase
virtual void Scale(const Vector3d&, const TRANSFORM *);
virtual void Transform(const TRANSFORM *);
virtual void Compute_BBox();
virtual bool IsOpaque() const override;

void Determine_Textures(Intersection *, bool, WeightedTextureVector&, TraceThreadData *);

Blob_List_Struct *Create_Blob_List_Element();
void Create_Blob_Element_Texture_List(Blob_List_Struct *BlobList, int npoints);
int Make_Blob(DBL threshold, Blob_List_Struct *bloblist, int npoints, TraceThreadData *Thread);

void Test_Blob_Opacity();

static void Translate_Blob_Element(Blob_Element *Element, const Vector3d& Vector);
static void Rotate_Blob_Element(Blob_Element *Element, const Vector3d& Vector);
static void Scale_Blob_Element(Blob_Element *Element, const Vector3d& Vector);
Expand Down
31 changes: 11 additions & 20 deletions source/core/shape/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2201,32 +2201,23 @@ bool Mesh::Degenerate(const Vector3d& P1, const Vector3d& P2, const Vector3d& P3
*
******************************************************************************/

void Mesh::Test_Mesh_Opacity()
bool Mesh::IsOpaque() const
{
MeshIndex i;

/* Initialize opacity flag to the opacity of the object's texture. */

if ((Texture == nullptr) || (Test_Opacity(Texture)))
{
Set_Flag(this, OPAQUE_FLAG);
}

if (Test_Flag(this, MULTITEXTURE_FLAG))
{
for (i = 0; i < Number_Of_Textures; i++)
for (MeshIndex i = 0; i < Number_Of_Textures; i++)
{
if (Textures[i] != nullptr)
{
/* If component's texture isn't opaque the mesh is neither. */

if (!Test_Opacity(Textures[i]))
{
Clear_Flag(this, OPAQUE_FLAG);
}
}
// If component's texture isn't opaque the mesh is neither.
if ((Textures[i] != nullptr) && !Test_Opacity(Textures[i]))
return false;
}
}

// Otherwise it's a question of whether the common texture is opaque or not.
// TODO FIXME - other objects report as non-opaque if Texture == nullptr.
// TODO FIXME - other objects report as non-opaque if Interior_Texture present and non-opaque.
// What we probably really want here is `return ObjectBase::IsOpaque()`.
return (Texture == nullptr) || Test_Opacity(Texture);
}


Expand Down
3 changes: 1 addition & 2 deletions source/core/shape/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ class Mesh : public ObjectBase
virtual void Scale(const Vector3d&, const TRANSFORM *);
virtual void Transform(const TRANSFORM *);
virtual void Compute_BBox();

void Test_Mesh_Opacity();
virtual bool IsOpaque() const override;

void Create_Mesh_Hash_Tables();

Expand Down
Loading

0 comments on commit d359466

Please sign in to comment.