Eliminate a potential (if unlikely) memory leak: Free a
authorscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 4 Nov 2009 20:53:20 +0000 (20:53 +0000)
committerscottmk <scottmk@9efc2488-bf62-4759-914b-345cdb29e865>
Wed, 4 Nov 2009 20:53:20 +0000 (20:53 +0000)
transport_message.error_type before overlaying it.

M    src/libopensrf/transport_message.c

git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1842 9efc2488-bf62-4759-914b-345cdb29e865

src/libopensrf/transport_message.c

index f59c6a4..dfe83d1 100644 (file)
@@ -495,7 +495,9 @@ void set_msg_error( transport_message* msg, const char* type, int err_code ) {
        if( !msg ) return;
 
        if( type != NULL && *type ) {
-               msg->error_type = safe_malloc( strlen(type)+1);
+               if( msg->error_type )
+                       free( msg->error_type );
+               msg->error_type = safe_malloc( strlen(type)+1 );
                strcpy( msg->error_type, type );
                msg->error_code = err_code;
        }