From 2601c629e20eda16e060142be4250b4a29392c3a Mon Sep 17 00:00:00 2001 From: kevin Date: Wed, 29 Dec 2021 21:46:54 -0500 Subject: [PATCH] cwPianoScore.cpp : Copy object values into internal data structure with strncpy() instead of memcpy() to eliminate possible memory corruption. Fixed memory leaks. --- cwPianoScore.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cwPianoScore.cpp b/cwPianoScore.cpp index 1b15c51..dc9f111 100644 --- a/cwPianoScore.cpp +++ b/cwPianoScore.cpp @@ -88,13 +88,13 @@ namespace cw if( sci_pitch != nullptr ) - memcpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch)); + strncpy(e->sci_pitch,sci_pitch,sizeof(e->sci_pitch)); if( dmark != nullptr ) - memcpy(e->dmark,dmark,sizeof(e->dmark)); + strncpy(e->dmark,dmark,sizeof(e->dmark)); if( grace_mark != nullptr ) - memcpy(e->grace_mark,grace_mark,sizeof(e->grace_mark)); + strncpy(e->grace_mark,grace_mark,sizeof(e->grace_mark)); // assign the UID e->uid = i; @@ -150,6 +150,10 @@ cw::rc_t cw::score::create( handle_t& hRef, const char* fn ) rc = create(hRef,cfg); errLabel: + + if( cfg != nullptr ) + cfg->free(); + return rc; }