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) char **ret_time)
{ {
int result = -1; int result = -1;
char *docId = NULL;
char *timestamp = NULL;
CESDLVolume *sdlVol = _DtHelpCeGetSdlVolumePtr(volume); CESDLVolume *sdlVol = _DtHelpCeGetSdlVolumePtr(volume);
if (sdlVol->sdl_info != NULL) if (sdlVol->sdl_info != NULL)
{ {
result = 0; result = 0;
if (NULL != _SdlDocInfoPtrDocId(sdlVol->sdl_info)) char *tmp = _SdlDocInfoPtrDocId(sdlVol->sdl_info);
docId = strdup(_SdlDocInfoPtrDocId(sdlVol->sdl_info)); if (NULL != tmp) {
else if (ret_doc != NULL) {
result = -2; *ret_doc = strdup(tmp);
if (*ret_doc == NULL)
if (NULL != _SdlDocInfoPtrStamp(sdlVol->sdl_info)) return -1;
timestamp = strdup(_SdlDocInfoPtrStamp(sdlVol->sdl_info)); }
else } else {
result = -2; result = -2;
} }
if (ret_doc != NULL) tmp = _SdlDocInfoPtrStamp(sdlVol->sdl_info);
*ret_doc = docId; if (NULL != tmp) {
if (ret_time != NULL) if (ret_time != NULL) {
*ret_time = timestamp; *ret_time = strdup(tmp);
if (*ret_time == NULL)
if (result == 0 && (docId == NULL || timestamp == NULL)) {
free(docId); /* Incase only one of them is NULL */
free(timestamp); /* " */
return -1; return -1;
} }
} else {
result = -2;
}
}
return result; return result;
} }

View File

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

View File

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

View File

@@ -313,6 +313,7 @@ DmxMsg::display (void)
env.logError(DTM_FALSE, "DEBUG dtmailpr: v3_cs = %s\n", v3_cs); env.logError(DTM_FALSE, "DEBUG dtmailpr: v3_cs = %s\n", v3_cs);
#endif #endif
} }
delete [] v3_cs;
to_cs = firstPart->locToConvName(); to_cs = firstPart->locToConvName();
#ifdef DEBUG #ifdef DEBUG
@@ -358,16 +359,11 @@ DmxMsg::display (void)
if (converted && contents) if (converted && contents)
free(contents); free(contents);
char *numbuf = new char [10241]; char *msgh = printHeader(MSGHEADER);
memset (numbuf, 0, 1024); puts(msgh);
#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));
puts(buf); puts(buf);
delete [] buf;
delete [] msgh;
fflush(stdout); fflush(stdout);
@@ -418,12 +414,12 @@ DmxMsg::display (void)
printf ("[%d] \"%s\"%s, ", i, name, description); printf ("[%d] \"%s\"%s, ", i, name, description);
printf ("%s, %lu bytes\n", type, length); printf ("%s, %lu bytes\n", type, length);
if (attbuf != NULL) if (attbuf != NULL) {
delete [] attbuf; delete [] attbuf;
attbuf = NULL;
}
} }
delete [] v3_cs;
return; return;
} }