Skip to content

Commit d359466

Browse files
committed
Merge branch 'master' into coverity_scan
2 parents 0b828e1 + 8fc5463 commit d359466

File tree

16 files changed

+196
-89
lines changed

16 files changed

+196
-89
lines changed

changes.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ Changed Behaviour
5656
by directives (stuff that begins with `#`).
5757
- UV mapping of cylinder, cone and lemon primitives has been disabled again
5858
for now, due to their orientation being poorly defined.
59+
- An age-old bug in the inbuilt `f_enneper` isosurface function has been
60+
fixed; the function now results in the originally intended shape.
5961

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

104+
Reported by Coverity static code analysis:
105+
106+
- CID 986462,986463 (Wrapper object use after free)
107+
- CID 967358-967362 (Uninitialized scalar variable)
108+
- CID 1372542-1372544 (Result is not floating-point)
109+
- CID 1372618 (Uninitialized scalar variable)
110+
- CID 1372629 (Uninitialized pointer read)
111+
- CID 1372630-1372632 (Uninitialized scalar variable)
112+
102113
Miscellaneous:
103114

104115
- Fix `interior_texture` for text objects (as mentioned in GitHub issue #65)

distribution/include/functions.inc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,12 @@
163163
// 2. y scale (inverse)
164164
// 3. z scale (inverse)
165165

166-
#declare f_enneper = function { internal(18) }
166+
#if (Functions_Inc_Temp < 3.8)
167+
#declare deprecated once "f_enneper was broken prior to v3.8; results will most likely differ."
168+
f_enneper = function { internal(18) }
169+
#else
170+
#declare f_enneper = function { internal(18) }
171+
#end
167172
// Parameters: x, y, z
168173
// One extra parameter required:
169174
// 1. Field strength

revision.txt

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,113 @@ Notes:
3535
POV-Ray v3.8.0-???
3636
------------------------------------------------------------------------------
3737

38+
Commit 915abb22 on 2018-09-12 by Christoph Lipka
39+
40+
Fix uninitialized variables in photons code discovered by static code
41+
analysis (CID 1372618, CID 1372630-1372632).
42+
Also placate static code analysis about a few others in user function
43+
VM code (CID 967358-967362).
44+
45+
Commit 65bd3196 on 2018-09-12 by Christoph Lipka
46+
47+
Fix bug in OpenEXR file handling code found by static code analysis
48+
(CID 986462 and 986463).
49+
50+
Commit 7de830ce on 2018-09-12 by Christoph Lipka
51+
52+
Eliminate C-style memory allocation in parametric.
53+
54+
Commit 7fa6bb53 on 2018-09-12 by Christoph Lipka
55+
56+
Refactor flagging of opaque objects during parser post-processing.
57+
58+
Commit 6fdadbde on 2018-09-12 by Christoph Lipka
59+
60+
[windows] Fix error in recent commit 917a8763 that broke the build.
61+
62+
Commit 24700edb on 2018-09-12 by Christoph Lipka
63+
64+
Eliminate C-style memory allocation in polygon.
65+
66+
Commit 917a8763 on 2018-09-12 by Christoph Lipka
67+
68+
Get rid of C-style `NULL` throughout the code in favour of the less
69+
ambiguous C++11-style `nullptr`.
70+
71+
Commit 72cf1a73 on 2018-09-12 by Christoph Lipka
72+
73+
Replace more magic constants in POVMS.
74+
75+
Commit aa0b48d7 on 2018-09-12 by Christoph Lipka
76+
77+
Clean up use of boolean values in POVMS.
78+
79+
Commit 49873bf9 on 2018-09-12 by Christoph Lipka
80+
81+
Improve code clarity with regards to POVMS return values, fixing a few
82+
bugs along the way.
83+
84+
Commit dfda62b7 on 2018-09-12 by Christoph Lipka
85+
86+
Minor update to stack size configuration.
87+
88+
Commit 72862c76 on 2018-09-12 by Christoph Lipka
89+
90+
Minor code simplification in quadrics code.
91+
92+
Commit 7bde9196 on 2018-09-12 by Christoph Lipka
93+
94+
Update various comments and a few text strings.
95+
96+
Commit 344ed893 on 2018-09-11 by Christoph Lipka
97+
98+
Update to `.gitattribute`; most notably, prevent auto-merging of
99+
`source/base/version.h`.
100+
101+
Commit 8a43226e on 2018-09-11 by Christoph Lipka
102+
103+
Minor update to `source/base/build.h` and related docs.
104+
105+
Commit 96489d42 on 2018-09-09 by Christoph Lipka
106+
107+
[unix] Make `.configure` script `COMPILED_BY` parameter optional,
108+
defaulting to login name.
109+
110+
Commit 63580949 on 2018-09-09 by Christoph Lipka
111+
112+
Fix bug introduced with commit 1d120c90.
113+
114+
Commit 0984776b on 2018-09-09 by Christoph Lipka
115+
116+
Update git pre-commit hook. Please copy `tools/git/hooks/pre-commit`
117+
to `.git/hooks/`.
118+
119+
Commit 2843d762 on 2018-09-08 by Christoph Lipka
120+
121+
Fix blatant coding error in POVMS UCS2 string handling.
122+
123+
Commit 264fa229 on 2018-09-07 by Christoph Lipka
124+
125+
Fix clang build error introduced with previous commit, and silence a
126+
few more clang warnings.
127+
128+
Commit 1d120c90 on 2018-09-07 by Christoph Lipka
129+
130+
Silence some clang warnings.
131+
132+
Commit f09a7b4f on 2018-09-02 by Christoph Lipka
133+
134+
Disable new UV mappings of cylinder, cone and lemon primitives for now.
135+
136+
Commit d20c6d42 on 2018-08-27 by Christoph Lipka
137+
138+
Improve `#breakpoint` debugging aid.
139+
Also update changelog.
140+
141+
------------------------------------------------------------------------------
142+
POV-Ray v3.8.0-alpha.9811560
143+
------------------------------------------------------------------------------
144+
38145
Commit c42e14e7 on 2018-08-27 by Christoph Lipka
39146

40147
Fix hard crash in `#declare Foo[A][B]=...` if `Foo` is an array of

source/base/image/openexr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ class POV_EXR_OStream : public Imf::OStream
9090
POV_EXR_OStream(pov_base::OStream& pov_stream) : Imf::OStream(UCS2toASCIIString(pov_stream.Name()).c_str()), os(pov_stream) { }
9191
virtual ~POV_EXR_OStream() { }
9292

93-
const char *fileName() const { return UCS2toASCIIString(os.Name()).c_str(); }
94-
9593
void write(const char *c, int n)
9694
{
9795
if(os.write(c, n) == false)
@@ -130,7 +128,6 @@ class POV_EXR_IStream : public Imf::IStream
130128

131129
virtual ~POV_EXR_IStream() { }
132130

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

136133
bool read(char *c, int n)

source/core/lighting/photons.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,13 @@ void PhotonTrace::ComputeLightedTexture(MathColour& LightCol, ColourChannel&, co
530530
doDiffuse = 0;
531531
threadData->passThruPrev = true;
532532
}
533-
// else die
533+
else
534+
{
535+
// die
536+
doReflection = 0;
537+
doRefraction = 0;
538+
doDiffuse = 0;
539+
}
534540
}
535541
else
536542
{
@@ -571,7 +577,7 @@ void PhotonTrace::ComputeLightedTexture(MathColour& LightCol, ColourChannel&, co
571577
}
572578
#endif // PT_AMPLIFY_BUG
573579

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

577583
#ifndef PT_AMPLIFY_BUG

source/core/scene/object.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,12 @@ bool ObjectBase::Intersect_BBox(BBoxDirection variant, const BBoxVector3d& origi
927927
return false; // unreachable
928928
}
929929

930+
bool ObjectBase::IsOpaque() const
931+
{
932+
return Test_Opacity(Texture) &&
933+
((Interior_Texture == nullptr) || Test_Opacity(Interior_Texture));
934+
}
935+
930936
void ContainedByBox::ComputeBBox(BoundingBox& rBbox) const
931937
{
932938
rBbox.lowerLeft = BBoxVector3d(corner1);

source/core/scene/object.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,20 @@ class ObjectBase
263263
///
264264
virtual void DispatchShutdownMessages(GenericMessenger& messenger) {};
265265

266+
/// Test texture for opacity.
267+
///
268+
/// This method will be called by the parser as part of object post-processing,
269+
/// to test whether the object's material is guaranteed to be fully opaque.
270+
///
271+
/// The default implementation reports the object as opaque if if has a texture that is
272+
/// guaranteed to be opaque (as determined by @ref Test_Opacity()), and it has either no
273+
/// explicit interior texture or that texture is also guaranteed to be opaque.
274+
///
275+
/// Primitives with innate textures (such as blob or mesh) must override this method, and
276+
/// return false if any of their innate textures is potentially non-opaque.
277+
///
278+
virtual bool IsOpaque() const;
279+
266280
protected:
267281
explicit ObjectBase(const ObjectBase&) { }
268282
};

source/core/shape/blob.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,30 +2638,23 @@ int Blob::Make_Blob(DBL threshold, Blob_List_Struct *BlobList, int npoints, Trac
26382638
*
26392639
******************************************************************************/
26402640

2641-
void Blob::Test_Blob_Opacity()
2641+
bool Blob::IsOpaque() const
26422642
{
2643-
/* Initialize opacity flag to the opacity of the object's texture. */
2644-
2645-
if ((Texture == nullptr) || (Test_Opacity(Texture)))
2646-
{
2647-
Set_Flag(this, OPAQUE_FLAG);
2648-
}
2649-
26502643
if (Test_Flag(this, MULTITEXTURE_FLAG))
26512644
{
2652-
for (vector<TEXTURE*>::iterator i = Element_Texture.begin(); i != Element_Texture.end(); ++i)
2645+
for (auto&& elementTexture : Element_Texture)
26532646
{
2654-
if (*i != nullptr)
2655-
{
2656-
/* If component's texture isn't opaque the blob is neither. */
2657-
2658-
if (!Test_Opacity(*i))
2659-
{
2660-
Clear_Flag(this, OPAQUE_FLAG);
2661-
}
2662-
}
2647+
// If component's texture isn't opaque the blob is neither.
2648+
if ((elementTexture != nullptr) && !Test_Opacity(elementTexture))
2649+
return false;
26632650
}
26642651
}
2652+
2653+
// Otherwise it's a question of whether the common texture is opaque or not.
2654+
// TODO FIXME - other objects report as non-opaque if Texture == nullptr.
2655+
// TODO FIXME - other objects report as non-opaque if Interior_Texture present and non-opaque.
2656+
// What we probably really want here is `return ObjectBase::IsOpaque()`.
2657+
return (Texture == nullptr) || Test_Opacity(Texture);
26652658
}
26662659

26672660

source/core/shape/blob.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,15 +155,14 @@ class Blob : public ObjectBase
155155
virtual void Scale(const Vector3d&, const TRANSFORM *);
156156
virtual void Transform(const TRANSFORM *);
157157
virtual void Compute_BBox();
158+
virtual bool IsOpaque() const override;
158159

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

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

165-
void Test_Blob_Opacity();
166-
167166
static void Translate_Blob_Element(Blob_Element *Element, const Vector3d& Vector);
168167
static void Rotate_Blob_Element(Blob_Element *Element, const Vector3d& Vector);
169168
static void Scale_Blob_Element(Blob_Element *Element, const Vector3d& Vector);

source/core/shape/mesh.cpp

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,32 +2201,23 @@ bool Mesh::Degenerate(const Vector3d& P1, const Vector3d& P2, const Vector3d& P3
22012201
*
22022202
******************************************************************************/
22032203

2204-
void Mesh::Test_Mesh_Opacity()
2204+
bool Mesh::IsOpaque() const
22052205
{
2206-
MeshIndex i;
2207-
2208-
/* Initialize opacity flag to the opacity of the object's texture. */
2209-
2210-
if ((Texture == nullptr) || (Test_Opacity(Texture)))
2211-
{
2212-
Set_Flag(this, OPAQUE_FLAG);
2213-
}
2214-
22152206
if (Test_Flag(this, MULTITEXTURE_FLAG))
22162207
{
2217-
for (i = 0; i < Number_Of_Textures; i++)
2208+
for (MeshIndex i = 0; i < Number_Of_Textures; i++)
22182209
{
2219-
if (Textures[i] != nullptr)
2220-
{
2221-
/* If component's texture isn't opaque the mesh is neither. */
2222-
2223-
if (!Test_Opacity(Textures[i]))
2224-
{
2225-
Clear_Flag(this, OPAQUE_FLAG);
2226-
}
2227-
}
2210+
// If component's texture isn't opaque the mesh is neither.
2211+
if ((Textures[i] != nullptr) && !Test_Opacity(Textures[i]))
2212+
return false;
22282213
}
22292214
}
2215+
2216+
// Otherwise it's a question of whether the common texture is opaque or not.
2217+
// TODO FIXME - other objects report as non-opaque if Texture == nullptr.
2218+
// TODO FIXME - other objects report as non-opaque if Interior_Texture present and non-opaque.
2219+
// What we probably really want here is `return ObjectBase::IsOpaque()`.
2220+
return (Texture == nullptr) || Test_Opacity(Texture);
22302221
}
22312222

22322223

0 commit comments

Comments
 (0)