OpenViBE Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000104openvibebug reportpublic2012-04-26 13:022012-05-03 15:15
Reporterantona 
Assigned Tojlegeny 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformWindowsOSXPOS VersionXP
Summary0000104: Deletion of unallocated memory
DescriptionProject: OpenViBE-plugins-file-io-dynamic

File: ovpCGDFFileWriter.cpp

Function:
void CGDFFileWriter::setValue(const uint32 ui32ValueIdentifier, const char* sValue)

If "sValue" is empty then strlen returns "0" and then the allocated memory for "l_pFormattedSubjectName" is 0, but then we delete it.
Steps To ReproduceThis problem was detected by Microsoft VC++ compiler in debug mode.
Additional InformationThis code fixes the problem:

case IBoxAlgorithmExperimentInformationInputReaderCallback::Value_SubjectName:
        {
            if (strlen(sValue)>0)
            {
                char * l_pFormattedSubjectName = new char[strlen(sValue)];

                strcpy(l_pFormattedSubjectName, sValue);

                char * l_pSpaceInSubjectName;
                //replaces all spaces by underscores
                while( (l_pSpaceInSubjectName = strchr(l_pFormattedSubjectName , ' ')) != NULL)
                {
                    *l_pSpaceInSubjectName = '_';
                }

                sprintf(m_oFixedHeader.m_sPatientId + 31, "%s", "Anton");//changed by Anton to test problem

                delete[] l_pFormattedSubjectName;
            }
        }
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0001014)
antona (reporter)
2012-04-26 13:09

sprintf(m_oFixedHeader.m_sPatientId + 31, "%s", "Anton");

should be:

sprintf(m_oFixedHeader.m_sPatientId + 31, "%s", l_pFormattedSubjectName);
(0001016)
jlegeny (reporter)
2012-05-03 15:15

Thank you for the patch, it has been commited in r3235

- Issue History
Date Modified Username Field Change
2012-04-26 13:02 antona New Issue
2012-04-26 13:09 antona Note Added: 0001014
2012-05-03 15:15 jlegeny Note Added: 0001016
2012-05-03 15:15 jlegeny Status new => resolved
2012-05-03 15:15 jlegeny Resolution open => fixed
2012-05-03 15:15 jlegeny Assigned To => jlegeny


Copyright © 2000 - 2024 MantisBT Team
Powered by Mantis Bugtracker