Index: wp-includes/class-wp-xmlrpc-server.php
===================================================================
--- wp-includes/class-wp-xmlrpc-server.php	(revision 20635)
+++ wp-includes/class-wp-xmlrpc-server.php	(working copy)
@@ -1760,14 +1760,15 @@
 			return $this->error;
 		}
 
+		$page = get_page($page_id);
+		if ( ! $page )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
 		if ( !current_user_can( 'edit_page', $page_id ) )
 			return new IXR_Error( 401, __( 'Sorry, you cannot edit this page.' ) );
 
 		do_action('xmlrpc_call', 'wp.getPage');
 
-		// Lookup page info.
-		$page = get_page($page_id);
-
 		// If we found the page then format the data.
 		if ( $page->ID && ($page->post_type == 'page') ) {
 			// Get all of the page content and link.
@@ -3208,13 +3209,15 @@
 		if ( !$user = $this->login($username, $password) )
 			return $this->error;
 
+		$post_data = wp_get_single_post($post_ID, ARRAY_A);
+		if ( ! $post_data )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+			
 		if ( !current_user_can( 'edit_post', $post_ID ) )
 			return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
 		do_action('xmlrpc_call', 'blogger.getPost');
 
-		$post_data = wp_get_single_post($post_ID, ARRAY_A);
-
 		$categories = implode(',', wp_get_post_categories($post_ID));
 
 		$content  = '<title>'.stripslashes($post_data['post_title']).'</title>';
@@ -4158,13 +4161,15 @@
 		if ( !$user = $this->login($username, $password) )
 			return $this->error;
 
+		$postdata = wp_get_single_post($post_ID, ARRAY_A);
+		if ( ! $postdata )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
 		if ( !current_user_can( 'edit_post', $post_ID ) )
 			return new IXR_Error( 401, __( 'Sorry, you cannot edit this post.' ) );
 
 		do_action('xmlrpc_call', 'metaWeblog.getPost');
 
-		$postdata = wp_get_single_post($post_ID, ARRAY_A);
-
 		if ($postdata['post_date'] != '') {
 			$post_date = $this->_convert_date( $postdata['post_date'] );
 			$post_date_gmt = $this->_convert_date_gmt( $postdata['post_date_gmt'],  $postdata['post_date'] );
@@ -4626,6 +4631,9 @@
 		if ( !$user = $this->login($username, $password) )
 			return $this->error;
 
+		if ( ! get_post( $post_ID ) )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
 		if ( !current_user_can( 'edit_post', $post_ID ) )
 			return new IXR_Error( 401, __( 'Sorry, you can not edit this post.' ) );
 
@@ -4669,6 +4677,9 @@
 
 		do_action('xmlrpc_call', 'mt.setPostCategories');
 
+		if ( ! get_post( $post_ID ) )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
 		if ( !current_user_can('edit_post', $post_ID) )
 			return new IXR_Error(401, __('Sorry, you cannot edit this post.'));
 
@@ -4776,11 +4787,13 @@
 
 		do_action('xmlrpc_call', 'mt.publishPost');
 
+		$postdata = wp_get_single_post($post_ID,ARRAY_A);
+		if ( ! $postdata )
+			return new IXR_Error( 404, __( 'Invalid post ID.' ) );
+
 		if ( !current_user_can('publish_posts') || !current_user_can('edit_post', $post_ID) )
 			return new IXR_Error(401, __('Sorry, you cannot publish this post.'));
 
-		$postdata = wp_get_single_post($post_ID,ARRAY_A);
-
 		$postdata['post_status'] = 'publish';
 
 		// retain old cats
