Fix memory leaks

This commit is contained in:
Patrick Georgi
2025-12-14 11:54:14 +01:00
parent ae767ed3dc
commit b86eff35f0
4 changed files with 31 additions and 31 deletions

View File

@@ -1359,34 +1359,33 @@ _DtHelpCeGetSdlDocStamp(
char **ret_time)
{
int result = -1;
char *docId = NULL;
char *timestamp = NULL;
CESDLVolume *sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
if (sdlVol->sdl_info != NULL)
{
result = 0;
if (NULL != _SdlDocInfoPtrDocId(sdlVol->sdl_info))
docId = strdup(_SdlDocInfoPtrDocId(sdlVol->sdl_info));
else
result = -2;
if (NULL != _SdlDocInfoPtrStamp(sdlVol->sdl_info))
timestamp = strdup(_SdlDocInfoPtrStamp(sdlVol->sdl_info));
else
char *tmp = _SdlDocInfoPtrDocId(sdlVol->sdl_info);
if (NULL != tmp) {
if (ret_doc != NULL) {
*ret_doc = strdup(tmp);
if (*ret_doc == NULL)
return -1;
}
} else {
result = -2;
}
if (ret_doc != NULL)
*ret_doc = docId;
if (ret_time != NULL)
*ret_time = timestamp;
if (result == 0 && (docId == NULL || timestamp == NULL)) {
free(docId); /* Incase only one of them is NULL */
free(timestamp); /* " */
tmp = _SdlDocInfoPtrStamp(sdlVol->sdl_info);
if (NULL != tmp) {
if (ret_time != NULL) {
*ret_time = strdup(tmp);
if (*ret_time == NULL)
return -1;
}
} else {
result = -2;
}
}
return result;
}

View File

@@ -95,6 +95,7 @@ text_string = (char *)calloc (1, sizeof (char));
if (xmstring) {
if (!XmStringInitContext (&context, xmstring)) {
printf("Can't convert compound string.\n");
free(text_string);
return (NULL);
}
while (XmStringGetNextSegment (context, &temp, &charset,

View File

@@ -373,6 +373,7 @@ RoamMenuWindow::restoreSession(char *buf)
{
fscanf(fp,"%s[\n]",buf);
LOG_CLOSEFILEPTR(log);
delete [] workspaces;
return NULL;
}
@@ -472,6 +473,7 @@ RoamMenuWindow::restoreSession(char *buf)
rmw->manage();
}
delete [] workspaces;
LOG_CLOSEFILEPTR(log);
return rmw;
}
@@ -594,6 +596,7 @@ SendMsgDialog::restoreSession(char *buf)
{
fscanf(fp,"%s[\n]",buf);
LOG_CLOSEFILEPTR(log);
delete [] workspaces;
return;
}
@@ -671,6 +674,7 @@ SendMsgDialog::restoreSession(char *buf)
smd->manage();
}
delete [] workspaces;
LOG_CLOSEFILEPTR(log);
}

View File

@@ -313,6 +313,7 @@ DmxMsg::display (void)
env.logError(DTM_FALSE, "DEBUG dtmailpr: v3_cs = %s\n", v3_cs);
#endif
}
delete [] v3_cs;
to_cs = firstPart->locToConvName();
#ifdef DEBUG
@@ -358,16 +359,11 @@ DmxMsg::display (void)
if (converted && contents)
free(contents);
char *numbuf = new char [10241];
memset (numbuf, 0, 1024);
#ifdef NEVER
// Don't want "Message 1:" appearing in print output
sprintf (numbuf, "Messsage %s:\n%s\n",
addlInfo, printHeader (MSGHEADER));
#endif
puts(printHeader(MSGHEADER));
char *msgh = printHeader(MSGHEADER);
puts(msgh);
puts(buf);
delete [] buf;
delete [] msgh;
fflush(stdout);
@@ -418,12 +414,12 @@ DmxMsg::display (void)
printf ("[%d] \"%s\"%s, ", i, name, description);
printf ("%s, %lu bytes\n", type, length);
if (attbuf != NULL)
if (attbuf != NULL) {
delete [] attbuf;
attbuf = NULL;
}
}
delete [] v3_cs;
return;
}