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 related to null checks after dereference

This commit is contained in:
Peter Howkins 2018-04-04 22:42:06 +01:00
parent 2b15c4057e
commit bc28c20524
6 changed files with 24 additions and 22 deletions

View file

@ -70,29 +70,33 @@ base::base(object_dict* obj_dict,
num_cset_ptrs(0), num_list_ptrs(0),
f_obj_dict(obj_dict)
{
int len = MIN(strlen(base_dir), PATHSIZ - 1);
if ( base_dir )
if ( base_dir ) {
int len = MIN(strlen(base_dir), PATHSIZ - 1);
*((char *) memcpy (base_path, base_dir, len) + len) = '\0';
else
} else {
base_path[0] = 0;
}
len = MIN(strlen(base_nm), PATHSIZ - 1);
if ( base_nm )
if ( base_nm ) {
int len = MIN(strlen(base_nm), PATHSIZ - 1);
*((char *) memcpy (base_name, base_nm, len) + len) = '\0';
else
} else {
base_name[0] = 0;
}
len = MIN(strlen(base_ds), PATHSIZ - 1);
if ( base_ds )
if ( base_ds ) {
int len = MIN(strlen(base_ds), PATHSIZ - 1);
*((char *) memcpy (base_desc, base_ds, len) + len) = '\0';
else
} else {
base_desc[0] = 0;
}
len = MIN(strlen(base_uid_str), UIDSIZ - 1);
if ( base_uid_str )
if ( base_uid_str ) {
int len = MIN(strlen(base_uid_str), UIDSIZ - 1);
*((char *) memcpy (base_uid, base_uid_str, len) + len) = '\0';
else
} else {
base_uid[0] = 0;
}
if ( set_nms )
while ( info_base_set_names[num_cset_ptrs] )

View file

@ -72,11 +72,12 @@ debug(cerr, base_dir);
debug(cerr, base_nm);
debug(cerr, base_ds);
*/
int len = MIN(strlen(base_locale), PATHSIZ - 1);
if (base_locale)
if (base_locale) {
int len = MIN(strlen(base_locale), PATHSIZ - 1);
*((char *) memcpy (info_base_locale, base_locale, len) + len) = '\0';
else
} else {
*info_base_locale = 0;
}
char* nm ;
int i;

View file

@ -530,8 +530,7 @@ highlight_search_hit(_DtCvSegment* seg, unsigned int vcc, unsigned int len)
}
DtCvStrVcLenSync(seg);
if (sibling->handle.string.string)
free (sibling->handle.string.string);
free (sibling->handle.string.string);
if (sibling->client_use) {
delete (SegClientData*)sibling->client_use;
sibling->client_use = NULL;

View file

@ -129,8 +129,7 @@ build_bc_url(UAS_String bookcase_path)
fprintf(stderr, "(DEBUG) URL=\"%s\"\n", (char*)bc_locator);
#endif
if (bc_path)
free(bc_path);
free(bc_path);
return bc_locator;
}

View file

@ -77,7 +77,7 @@ AusText::~AusText()
{
store->deActivateZone ( f_base );
if ( store ) { delete store; }
delete store;
if ( f_search_store ) { delete f_search_store; }
}

View file

@ -828,8 +828,7 @@ makeAbsPathEnv(char *var)
snprintf(newVar, pathlen, "%s=%s", var, newPath);
putenv(newVar);
if (newPath)
XtFree(newPath);
XtFree(newPath);
return newVar;
}