Mercurial > octave
changeset 26407:31b0761cd641 stable
gl-render.cc: Fix static analyzer detected issues (bug #55347).
* gl-render.cc (opengl_texture& operator =, vertex_data& operator =):
Check object to be assigned against this pointer before doing assignment.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 03 Jan 2019 10:50:11 -0800 |
parents | b352120504bc |
children | 25dfa8c96b7b |
files | libinterp/corefcn/gl-render.cc |
diffstat | 1 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc Thu Jan 03 13:23:45 2019 -0500 +++ b/libinterp/corefcn/gl-render.cc Thu Jan 03 10:50:11 2019 -0800 @@ -152,11 +152,14 @@ opengl_texture& operator = (const opengl_texture& tx) { - if (--rep->count == 0) - delete rep; - - rep = tx.rep; - rep->count++; + if (&tx != this) + { + if (--rep->count == 0) + delete rep; + + rep = tx.rep; + rep->count++; + } return *this; } @@ -429,11 +432,14 @@ vertex_data& operator = (const vertex_data& v) { - if (--rep->count == 0) - delete rep; - - rep = v.rep; - rep->count++; + if (&v != this) + { + if (--rep->count == 0) + delete rep; + + rep = v.rep; + rep->count++; + } return *this; }