server: Remove redundant NULL check before free() (found by Smatch).

This commit is contained in:
Michael Stefaniuc 2006-10-09 23:34:36 +02:00 committed by Alexandre Julliard
parent 2d48706d74
commit 5cecceccb2
14 changed files with 38 additions and 45 deletions

View File

@ -196,7 +196,7 @@ static void atom_table_destroy( struct object *obj )
for (i = 0; i <= table->last; i++) free( table->handles[i] );
free( table->handles );
}
if (table->entries) free( table->entries );
free( table->entries );
}
/* find an atom entry in its hash list */

View File

@ -474,8 +474,7 @@ static void inode_set_wd( struct inode *inode, int wd )
static void inode_set_name( struct inode *inode, const char *name )
{
if (inode->name)
free (inode->name);
free (inode->name);
inode->name = name ? strdup( name ) : NULL;
}

View File

@ -633,7 +633,7 @@ static int set_console_input_info( const struct set_console_input_info_request *
{
memcpy( new_title, title, len );
new_title[len / sizeof(WCHAR)] = 0;
if (console->title) free( console->title );
free( console->title );
console->title = new_title;
evt.event = CONSOLE_RENDERER_TITLE_EVENT;
console_input_events_append( console->evt, &evt );
@ -963,8 +963,8 @@ static void console_input_destroy( struct object *obj )
int i;
assert( obj->ops == &console_input_ops );
if (console_in->title) free( console_in->title );
if (console_in->records) free( console_in->records );
free( console_in->title );
free( console_in->records );
if (console_in->active) release_object( console_in->active );
console_in->active = NULL;
@ -980,7 +980,7 @@ static void console_input_destroy( struct object *obj )
for (i = 0; i < console_in->history_size; i++)
if (console_in->history[i]) free( console_in->history[i] );
if (console_in->history) free( console_in->history );
free( console_in->history );
}
static void screen_buffer_dump( struct object *obj, int verbose )
@ -1013,7 +1013,7 @@ static void screen_buffer_destroy( struct object *obj )
}
}
}
if (screen_buffer->data) free( screen_buffer->data );
free( screen_buffer->data );
}
/* write data into a screen buffer */

View File

@ -149,7 +149,7 @@ static struct hook *add_hook( struct desktop *desktop, struct thread *thread, in
static void free_hook( struct hook *hook )
{
free_user_handle( hook->handle );
if (hook->module) free( hook->module );
free( hook->module );
if (hook->thread)
{
assert( hook->thread->desktop_users > 0 );
@ -437,7 +437,7 @@ DECL_HANDLER(set_hook)
reply->handle = hook->handle;
reply->active_hooks = get_active_hooks();
}
else if (module) free( module );
else free( module );
done:
if (process) release_object( process );

View File

@ -305,7 +305,7 @@ static void mailslot_device_destroy( struct object *obj )
struct mailslot_device *device = (struct mailslot_device*)obj;
assert( obj->ops == &mailslot_device_ops );
if (device->fd) release_object( device->fd );
if (device->mailslots) free( device->mailslots );
free( device->mailslots );
}
static int mailslot_device_get_file_info( struct fd *fd )

View File

@ -196,7 +196,7 @@ static int build_shared_mapping( struct mapping *mapping, int fd,
error:
release_object( mapping->shared_file );
mapping->shared_file = NULL;
if (buffer) free( buffer );
free( buffer );
return 0;
}
@ -254,7 +254,7 @@ static int get_image_params( struct mapping *mapping )
return 1;
error:
if (sec) free( sec );
free( sec );
release_object( fd );
set_error( STATUS_INVALID_FILE_FOR_SECTION );
return 0;

View File

@ -435,7 +435,7 @@ static void named_pipe_device_destroy( struct object *obj )
struct named_pipe_device *device = (struct named_pipe_device*)obj;
assert( obj->ops == &named_pipe_device_ops );
if (device->fd) release_object( device->fd );
if (device->pipes) free( device->pipes );
free( device->pipes );
}
static int named_pipe_device_get_file_info( struct fd *fd )

View File

@ -417,7 +417,7 @@ static void startup_info_destroy( struct object *obj )
{
struct startup_info *info = (struct startup_info *)obj;
assert( obj->ops == &startup_info_ops );
if (info->data) free( info->data );
free( info->data );
if (info->exe_file) release_object( info->exe_file );
if (info->process) release_object( info->process );
}
@ -504,7 +504,7 @@ static void process_unload_dll( struct process *process, void *base )
if (dll && (&dll->entry != list_head( &process->dlls ))) /* main exe can't be unloaded */
{
if (dll->file) release_object( dll->file );
if (dll->filename) free( dll->filename );
free( dll->filename );
list_remove( &dll->entry );
free( dll );
generate_debug_event( current, UNLOAD_DLL_DEBUG_EVENT, base );
@ -582,7 +582,7 @@ static void process_killed( struct process *process )
{
struct process_dll *dll = LIST_ENTRY( ptr, struct process_dll, entry );
if (dll->file) release_object( dll->file );
if (dll->filename) free( dll->filename );
free( dll->filename );
list_remove( &dll->entry );
free( dll );
}

View File

@ -404,7 +404,7 @@ static int merge_message( struct thread_input *input, const struct message *msg
static void free_result( struct message_result *result )
{
if (result->timeout) remove_timeout_user( result->timeout );
if (result->data) free( result->data );
free( result->data );
if (result->callback_msg) free_message( result->callback_msg );
free( result );
}
@ -467,7 +467,7 @@ static void free_message( struct message *msg )
}
else free_result( result );
}
if (msg->data) free( msg->data );
free( msg->data );
free( msg );
}

View File

@ -327,20 +327,20 @@ static void key_destroy( struct object *obj )
struct key *key = (struct key *)obj;
assert( obj->ops == &key_ops );
if (key->name) free( key->name );
if (key->class) free( key->class );
free( key->name );
free( key->class );
for (i = 0; i <= key->last_value; i++)
{
if (key->values[i].name) free( key->values[i].name );
if (key->values[i].data) free( key->values[i].data );
}
if (key->values) free( key->values );
free( key->values );
for (i = 0; i <= key->last_subkey; i++)
{
key->subkeys[i]->parent = NULL;
release_object( key->subkeys[i] );
}
if (key->subkeys) free( key->subkeys );
free( key->subkeys );
/* unconditionally notify everything waiting on this key */
while ((ptr = list_head( &key->notify_list )))
{
@ -656,7 +656,7 @@ static struct key *create_key( struct key *key, const struct unicode_str *name,
if (class && class->len)
{
key->classlen = class->len;
if (key->class) free(key->class);
free(key->class);
if (!(key->class = memdup( class->str, key->classlen ))) key->classlen = 0;
}
grab_object( key );
@ -887,11 +887,11 @@ static void set_value( struct key *key, const struct unicode_str *name,
{
if (!(value = insert_value( key, name, index )))
{
if (ptr) free( ptr );
free( ptr );
return;
}
}
else if (value->data) free( value->data ); /* already existing, free previous data */
else free( value->data ); /* already existing, free previous data */
value->type = type;
value->len = len;
@ -983,8 +983,8 @@ static void delete_value( struct key *key, const struct unicode_str *name )
return;
}
if (debug_level > 1) dump_operation( key, value, "Delete" );
if (value->name) free( value->name );
if (value->data) free( value->data );
free( value->name );
free( value->data );
for (i = index; i < key->last_value; i++) key->values[i] = key->values[i + 1];
key->last_value--;
touch_key( key, REG_NOTIFY_CHANGE_LAST_SET );
@ -1310,7 +1310,7 @@ static int load_value( struct key *key, const char *buffer, struct file_load_inf
if (!len) newptr = NULL;
else if (!(newptr = memdup( ptr, len ))) return 0;
if (value->data) free( value->data );
free( value->data );
value->data = newptr;
value->len = len;
value->type = type;

View File

@ -251,11 +251,8 @@ static void send_reply( union generic_reply *reply )
return;
}
}
if (current->reply_data)
{
free( current->reply_data );
current->reply_data = NULL;
}
free( current->reply_data );
current->reply_data = NULL;
return;
error:

View File

@ -213,12 +213,12 @@ static void cleanup_thread( struct thread *thread )
struct thread_apc *apc;
while ((apc = thread_dequeue_apc( thread, 0 ))) free( apc );
if (thread->req_data) free( thread->req_data );
if (thread->reply_data) free( thread->reply_data );
free( thread->req_data );
free( thread->reply_data );
if (thread->request_fd) release_object( thread->request_fd );
if (thread->reply_fd) release_object( thread->reply_fd );
if (thread->wait_fd) release_object( thread->wait_fd );
if (thread->suspend_context) free( thread->suspend_context );
free( thread->suspend_context );
free_msg_queue( thread );
cleanup_clipboard_thread(thread);
destroy_thread_windows( thread );

View File

@ -594,12 +594,9 @@ struct token *token_create_admin( void )
default_dacl, admin_source );
}
if (alias_admins_sid)
free( alias_admins_sid );
if (alias_users_sid)
free( alias_users_sid );
if (default_dacl)
free( default_dacl );
free( alias_admins_sid );
free( alias_users_sid );
free( default_dacl );
return token;
}

View File

@ -347,7 +347,7 @@ void destroy_window( struct window *win )
if (win->win_region) free_region( win->win_region );
if (win->update_region) free_region( win->update_region );
if (win->class) release_class( win->class );
if (win->text) free( win->text );
free( win->text );
memset( win, 0x55, sizeof(*win) + win->nb_extra_bytes - 1 );
free( win );
}
@ -1753,7 +1753,7 @@ DECL_HANDLER(set_window_text)
memcpy( text, get_req_data(), len * sizeof(WCHAR) );
text[len] = 0;
}
if (win->text) free( win->text );
free( win->text );
win->text = text;
}
}