1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtinfo: Fix coverity issues for resource leaks

This commit is contained in:
Peter Howkins 2018-04-04 22:07:10 +01:00
parent 9ef3b9ec68
commit 2b15c4057e
11 changed files with 47 additions and 13 deletions

View file

@ -172,8 +172,10 @@ __bt_sync(dbp, flags)
if (ISSET(t, B_DELCRSR)) { if (ISSET(t, B_DELCRSR)) {
if ((p = (void*)malloc(t->bt_psize)) == NULL) if ((p = (void*)malloc(t->bt_psize)) == NULL)
return (RET_ERROR); return (RET_ERROR);
if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) {
free(p);
return (RET_ERROR); return (RET_ERROR);
}
memmove(p, h, t->bt_psize); memmove(p, h, t->bt_psize);
if ((status = if ((status =
__bt_dleaf(t, h, t->bt_bcursor.index)) == RET_ERROR) __bt_dleaf(t, h, t->bt_bcursor.index)) == RET_ERROR)
@ -185,8 +187,10 @@ __bt_sync(dbp, flags)
CLR(t, B_MODIFIED); CLR(t, B_MODIFIED);
ecrsr: if (ISSET(t, B_DELCRSR)) { ecrsr: if (ISSET(t, B_DELCRSR)) {
if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, t->bt_bcursor.pgno, 0)) == NULL) {
free(p);
return (RET_ERROR); return (RET_ERROR);
}
memmove(h, p, t->bt_psize); memmove(h, p, t->bt_psize);
free(p); free(p);
mpool_put(t->bt_mp, h, MPOOL_DIRTY); mpool_put(t->bt_mp, h, MPOOL_DIRTY);

View file

@ -191,8 +191,10 @@ DtMmdbHandle** DtMmdbBookGetTabList(DtMmdbInfoRequest* request, unsigned int* le
while (*desc != '\0' && *desc != '\t') desc++; while (*desc != '\0' && *desc != '\t') desc++;
if (*desc != '\t') if (*desc != '\t') {
free(u);
return 0; return 0;
}
desc++; desc++;

View file

@ -413,15 +413,17 @@ Boolean page::_alloc_slot( int slot_num, int size, char*& str_ptr )
int new_blank_len = slot_info -> string_leng() ; int new_blank_len = slot_info -> string_leng() ;
if ( new_blank_len < size ) if ( new_blank_len < size ) {
delete slot_info;
return false; return false;
}
slot_info -> set_string_ofst( end_ptr ); slot_info -> set_string_ofst( end_ptr );
slot_info -> set_string_leng( size ); slot_info -> set_string_leng( size );
slot_info -> set_mode(spointer_t::DELETED, false); slot_info -> set_mode(spointer_t::DELETED, false);
slot_info -> set_forward_ptr(0); slot_info -> set_forward_ptr(0);
delete slot_info; delete slot_info;
if ( slot_num == count() ) { if ( slot_num == count() ) {

View file

@ -698,8 +698,10 @@ int page_storage::deleteString(mmdb_pos_t loc, Boolean flush_opt)
spointer_t *x = y -> get_spointer(slot_num); spointer_t *x = y -> get_spointer(slot_num);
if ( x -> get_mode(spointer_t::DELETED) == true ) if ( x -> get_mode(spointer_t::DELETED) == true ) {
delete x;
return 0; return 0;
}
loc = x -> forward_ptr(); loc = x -> forward_ptr();
//debug(cerr, loc); //debug(cerr, loc);

View file

@ -38,6 +38,7 @@ string::string(char* str, int size)
string::~string() string::~string()
{ {
delete sbuf;
} }
char* string::c_str() char* string::c_str()

View file

@ -1967,6 +1967,9 @@ LibraryAgent::transferCB(Widget w, XtPointer client_data, XtPointer call_data)
file = strdup(netfile); file = strdup(netfile);
if (file == NULL || *file == '\0') { if (file == NULL || *file == '\0') {
if(file) {
tt_free(file);
}
XtFree(netfile); XtFree(netfile);
XmTransferDone(cs->transfer_id, XmTRANSFER_DONE_FAIL); XmTransferDone(cs->transfer_id, XmTRANSFER_DONE_FAIL);
return; return;

View file

@ -202,8 +202,10 @@ void
MessageAgent::displayMessage (char *message_text) MessageAgent::displayMessage (char *message_text)
{ {
char *message_string = strdup(message_text); char *message_string = strdup(message_text);
if(f_dialog == NULL) if(f_dialog == NULL) {
free(message_string);
return; return;
}
XmStringLocalized mtfstring; XmStringLocalized mtfstring;
@ -245,8 +247,10 @@ MessageAgent::displayError (char *message_text, Widget parent)
char *message_string = strdup(message_text); char *message_string = strdup(message_text);
if (f_dialog == NULL) if (f_dialog == NULL)
create_ui(parent); create_ui(parent);
if (g_active) if (g_active) {
free(message_string);
return; return;
}
g_active = TRUE; g_active = TRUE;
// Set the window title // Set the window title
@ -282,8 +286,10 @@ MessageAgent::displayWarning (char *message_text, Widget parent)
char *message_string = strdup(message_text); char *message_string = strdup(message_text);
if (f_dialog == NULL) if (f_dialog == NULL)
create_ui(parent); create_ui(parent);
if (g_active) if (g_active) {
free(message_string);
return; return;
}
g_active = TRUE; g_active = TRUE;
// Set the window title // Set the window title
@ -319,8 +325,10 @@ MessageAgent::displayInformation (char *message_text, Widget parent)
if (f_dialog == NULL) if (f_dialog == NULL)
create_ui(parent); create_ui(parent);
if (g_active) if (g_active) {
free(message_string);
return; return;
}
g_active = TRUE; g_active = TRUE;
// Set the window title // Set the window title
@ -433,8 +441,10 @@ MessageAgent::displayQuestion (char *message_text, Widget parent)
if (f_dialog == NULL) if (f_dialog == NULL)
create_ui(parent); create_ui(parent);
if (g_active) if (g_active) {
free(message_string);
return (FALSE); return (FALSE);
}
g_active = TRUE; g_active = TRUE;
// Set the window title // Set the window title
@ -485,8 +495,10 @@ MessageAgent::displayQuit (char *message_text, Widget parent)
if (f_dialog == NULL) if (f_dialog == NULL)
create_ui(parent); create_ui(parent);
if (g_active) if (g_active) {
free(message_string);
return; return;
}
g_active = TRUE; g_active = TRUE;
// Set the window title // Set the window title

View file

@ -818,10 +818,11 @@ a human readable character string.
static void static void
OutputAnAtomName(Widget w, Atom target) OutputAnAtomName(Widget w, Atom target)
{ {
char *AtomName = (char *)malloc(sizeof(char *) * 34); char *AtomName = NULL;
AtomName = XGetAtomName(XtDisplay(w), target); AtomName = XGetAtomName(XtDisplay(w), target);
printf("\t%s\n", AtomName); printf("\t%s\n", AtomName);
XFree(AtomName);
} }
// ///////////////////////////////////////////////////////////////// // /////////////////////////////////////////////////////////////////
@ -934,12 +935,14 @@ OutlineListView::printConvertCallback(WCallback *wcb)
// write out the locator // write out the locator
if (fputs(((TOC_Element *)te)->toc()->locator(), fp) == EOF) { if (fputs(((TOC_Element *)te)->toc()->locator(), fp) == EOF) {
fprintf(stderr, "Cannot write file %s in current directory.\n", filepath); fprintf(stderr, "Cannot write file %s in current directory.\n", filepath);
fclose(fp);
return; return;
} }
// write out eol // write out eol
if (fputs("\n", fp) == EOF) { if (fputs("\n", fp) == EOF) {
fprintf(stderr, "Cannot write file %s in current directory.\n", filepath); fprintf(stderr, "Cannot write file %s in current directory.\n", filepath);
fclose(fp);
return; return;
} }

View file

@ -398,6 +398,7 @@ pattern_done:
printf("pattern = %s.\n", pattern); printf("pattern = %s.\n", pattern);
#endif #endif
xlfd = strdup(pattern); xlfd = strdup(pattern);
free(dupfallback);
return(xlfd); return(xlfd);
} }
@ -456,6 +457,8 @@ pattern_done:
#ifdef FONT_DEBUG #ifdef FONT_DEBUG
printf("xlfd = %s.\n", xlfd); printf("xlfd = %s.\n", xlfd);
#endif #endif
free(dupfallback);
return(xlfd); return(xlfd);
} }

View file

@ -149,6 +149,7 @@ SearchPath::get_real_path( const char *file_name )
fclose( fp ); fclose( fp );
return ( full_path_name ); return ( full_path_name );
} }
fclose( fp );
} }
return NULL; return NULL;

View file

@ -533,6 +533,7 @@ void StyleTask::write_record( void )
else { else {
Token::signalError(Token::User, Token::Continuable, 0, 0, Token::signalError(Token::User, Token::Continuable, 0, 0,
"Duplicate stylesheet id `%s'", localstr); "Duplicate stylesheet id `%s'", localstr);
delete bogus;
return; return;
} }