From 6d9206224daf21a6a401da46011f4c5960690b4c Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Mon, 1 Sep 2008 10:48:28 +0000 Subject: [PATCH] Added call to free in setValue methods to prevent potential memory leak --- include/osgSim/ShapeAttribute | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/osgSim/ShapeAttribute b/include/osgSim/ShapeAttribute index d5b113aac..aab7ce8b3 100644 --- a/include/osgSim/ShapeAttribute +++ b/include/osgSim/ShapeAttribute @@ -61,9 +61,9 @@ class OSGSIM_EXPORT ShapeAttribute double getDouble() const { return _double; } const char * getString() const { return _string; } - void setValue(int value) {_type = INTEGER; _integer = value; } - void setValue(double value) {_type = DOUBLE; _double = value; } - void setValue(const char * value) {_type = STRING; _string = (value ? strdup(value) : 0); } + void setValue(int value) { free(); _type = INTEGER; _integer = value; } + void setValue(double value) { free(); _type = DOUBLE; _double = value; } + void setValue(const char * value) { free(); _type = STRING; _string = (value ? strdup(value) : 0); } /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ int compare(const osgSim::ShapeAttribute& sa) const;