summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorkonrad.r <konrad.r>2005-08-11 15:10:48 +0000
committerkonrad.r <konrad.r>2005-08-11 15:10:48 +0000
commit1b23caec9ef019a7e95c278a7d413aa095845488 (patch)
tree0f386e94bdc5f670abbe3edf4f48d78529f3e177 /src
parent8d1810ff92bf110f2f77b583e3c5d0bf009a5643 (diff)
downloadtog-pegasus-1b23caec9ef019a7e95c278a7d413aa095845488.zip
tog-pegasus-1b23caec9ef019a7e95c278a7d413aa095845488.tar.gz
tog-pegasus-1b23caec9ef019a7e95c278a7d413aa095845488.tar.xz
BUG#: 4063
TITLE: Memory leak in dtGetBinaryFormat (CMPI_DateTime.cpp) DESCRIPTION:
Diffstat (limited to 'src')
-rw-r--r--src/Pegasus/ProviderManager2/CMPI/CMPI_DateTime.cpp6
-rw-r--r--src/Providers/TestProviders/CMPI/TestMethod/cmpiTestMethodProvider.c19
-rw-r--r--src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.cpp24
-rw-r--r--src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.loggood9
-rw-r--r--src/Providers/TestProviders/Load/TestCMPI_ProviderSchema.mof1
5 files changed, 56 insertions, 3 deletions
diff --git a/src/Pegasus/ProviderManager2/CMPI/CMPI_DateTime.cpp b/src/Pegasus/ProviderManager2/CMPI/CMPI_DateTime.cpp
index 8f7aeda..1de61f7 100644
--- a/src/Pegasus/ProviderManager2/CMPI/CMPI_DateTime.cpp
+++ b/src/Pegasus/ProviderManager2/CMPI/CMPI_DateTime.cpp
@@ -182,8 +182,9 @@ extern "C" {
CMPIUint64 days,hours,mins,secs,usecs,utc,lTime;
struct tm tm,tmt;
CString tStr=dt->toString().getCString();
- char *cStr=strdup((const char*)tStr);
-
+ char cStr[26];
+ memset( cStr, 0, 26);
+ memcpy (cStr, (const char*)tStr, 25);
if (dt->isInterval()) {
cStr[21]=0;
usecs=atoi(cStr+15);
@@ -224,7 +225,6 @@ extern "C" {
tm.tm_mon=(atoi(cStr+4)-1);
cStr[4]=0;
tm.tm_year=(atoi(cStr)-1900);
-
lTime=mktime(&tm);
lTime*=1000000;
lTime+=usecs;
diff --git a/src/Providers/TestProviders/CMPI/TestMethod/cmpiTestMethodProvider.c b/src/Providers/TestProviders/CMPI/TestMethod/cmpiTestMethodProvider.c
index 25f532f..8f90cdd 100644
--- a/src/Providers/TestProviders/CMPI/TestMethod/cmpiTestMethodProvider.c
+++ b/src/Providers/TestProviders/CMPI/TestMethod/cmpiTestMethodProvider.c
@@ -676,6 +676,25 @@ TestCMPIMethodProviderInvokeMethod (CMPIMethodMI * mi,
CMReturnData (rslt, (CMPIValue *) & instance, CMPI_instance);
CMReturnDone (rslt);
}
+ else if (strncmp("returnDateTime", methodName, strlen("returnDateTime")) == 0)
+ {
+ CMPIUint64 ret_val = 0;
+ CMPIStatus rc={CMPI_RC_OK, NULL};
+
+ CMPIDateTime *dateTime = CMNewDateTime(_broker, &rc);
+ PROV_LOG ("---- (rc:%s)", strCMPIStatus (rc));
+ // Checking the date.
+ ret_val = CMGetBinaryFormat (dateTime, &rc);
+ PROV_LOG ("---- (rc:%s)", strCMPIStatus (rc));
+ if (ret_val == 0)
+ PROV_LOG("Invalid conversion of date to CMPIDateTime");
+
+ PROV_LOG
+ ("++++ Calling CMReturnData+Done on returnDateTime operation");
+
+ CMReturnData (rslt, (CMPIValue *) & dateTime, CMPI_dateTime);
+ CMReturnDone (rslt);
+ }
else
{
PROV_LOG ("++++ Could not find the %s operation", methodName);
diff --git a/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.cpp b/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.cpp
index ce9a854..ecff780 100644
--- a/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.cpp
+++ b/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.cpp
@@ -318,6 +318,29 @@ test04 (CIMClient & client)
}
void
+test05 (CIMClient & client)
+{
+ CIMObjectPath instanceName;
+
+ instanceName.setNameSpace (PROVIDERNAMESPACE);
+ instanceName.setClassName (CLASSNAME);
+
+ Array < CIMParamValue > inParams;
+ Array < CIMParamValue > outParams;
+
+ /* String returnDateTime(); */
+
+ CIMValue retValue = client.invokeMethod (PROVIDERNAMESPACE,
+ instanceName,
+ "returnDateTime",
+ inParams,
+ outParams);
+ PEGASUS_ASSERT (retValue.getType () == CIMTYPE_DATETIME);
+ PEGASUS_ASSERT (!retValue.isArray ());
+ PEGASUS_ASSERT (!retValue.isNull ());
+
+}
+void
_test (CIMClient & client)
{
try
@@ -327,6 +350,7 @@ _test (CIMClient & client)
test02 (client);
test03 (client);
test04 (client);
+ test05 (client);
}
catch (Exception & e)
{
diff --git a/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.loggood b/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.loggood
index 843ced4..b4407b2 100644
--- a/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.loggood
+++ b/src/Providers/TestProviders/CMPI/TestMethod/tests/TestCMPIMethod.loggood
@@ -131,3 +131,12 @@
---- Object path is root/cimv2:TestCMPI_Instance.ElementName="Fake_ObjPath" (rc:CMPI_RC_OK)
++++ Calling CMReturnData+Done on returnInstance operation
--- TestCMPI_Method CMPI InvokeMethod() exited
+ --- TestCMPI_Method CMPI InvokeMethod() called
+ InvokeMethod: checking for correct classname [TestCMPI_Method]
+ Calling CMGetArgCount
+ ++++ (CMPI_RC_OK)
+ InvokeMethod: We have 0 arguments for operation [returnDateTime]:
+ ---- (rc:CMPI_RC_OK)
+ ---- (rc:CMPI_RC_OK)
+ ++++ Calling CMReturnData+Done on returnDateTime operation
+ --- TestCMPI_Method CMPI InvokeMethod() exited
diff --git a/src/Providers/TestProviders/Load/TestCMPI_ProviderSchema.mof b/src/Providers/TestProviders/Load/TestCMPI_ProviderSchema.mof
index 8d1a71d..1acbe7f 100644
--- a/src/Providers/TestProviders/Load/TestCMPI_ProviderSchema.mof
+++ b/src/Providers/TestProviders/Load/TestCMPI_ProviderSchema.mof
@@ -48,6 +48,7 @@ class TestCMPI_Method : TestCMPI_Parent
Uint32 returnUint32();
[EmbeddedObject]
string returnInstance();
+ datetime returnDateTime();
};
class TestCMPI_Fail_1: TestCMPI_Parent