mirror of
https://github.com/nasa/trick.git
synced 2024-12-21 06:03:10 +00:00
Merge pull request #879 from nasa/udunits-bug
get rid of dangling pointer use closes #878
This commit is contained in:
commit
6625d41a63
@ -1,5 +1,6 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "trick/VariableServer.hh"
|
#include "trick/VariableServer.hh"
|
||||||
#include "trick/exec_proto.h"
|
#include "trick/exec_proto.h"
|
||||||
@ -530,11 +531,14 @@ int var_set_base( const char * var , T value , const char * units ) {
|
|||||||
v_tree.v_data = &v_data ;
|
v_tree.v_data = &v_data ;
|
||||||
var_set_value( v_data , value) ;
|
var_set_value( v_data , value) ;
|
||||||
if ( units != NULL ) {
|
if ( units != NULL ) {
|
||||||
ref->units = (char *)(map_trick_units_to_udunits(units).c_str()) ;
|
ref->units = strdup(map_trick_units_to_udunits(units).c_str()) ;
|
||||||
} else {
|
} else {
|
||||||
ref->units = (char *)units ;
|
ref->units = NULL ;
|
||||||
}
|
}
|
||||||
ref_assignment(ref , &v_tree) ;
|
ref_assignment(ref , &v_tree) ;
|
||||||
|
if(ref->units != NULL) {
|
||||||
|
free(ref->units) ;
|
||||||
|
}
|
||||||
free(ref) ;
|
free(ref) ;
|
||||||
} else {
|
} else {
|
||||||
message_publish(MSG_WARNING,"Cannot assign to %s because io_spec does not allow input\n", var) ;
|
message_publish(MSG_WARNING,"Cannot assign to %s because io_spec does not allow input\n", var) ;
|
||||||
|
Loading…
Reference in New Issue
Block a user