Index: xmlrpc.php
===================================================================
--- xmlrpc.php	(revision 12207)
+++ xmlrpc.php	(working copy)
@@ -612,14 +612,30 @@
 
 		do_action('xmlrpc_call', 'wp.getPages');
 
-		$pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => $num_pages) );
+		$many_pages = get_posts( array('post_type' => 'page', 'post_status' => 'all', 'numberposts' => ( $num_pages * 3 ) ) );
 		$num_pages = count($pages);
 
+		// Remove pages that are in the trash
+		$pages = array( );
+		foreach ( (array) $many_pages as $a_page ) {
+			if ( $a_page->post_status == 'trash' )
+				continue;
+
+			$pages[] = $a_page;
+		}
+
+		// Limit page count to the number requested
+		$total_pages = count($pages);
+		if ( $total_pages > $num_pages ) {
+			$pages = array_slice( $pages, 0, $num_pages - 1 );
+			$total_pages = $num_pages;
+		}
+
 		// If we have pages, put together their info.
-		if($num_pages >= 1) {
+		if($total_pages >= 1) {
 			$pages_struct = array();
 
-			for($i = 0; $i < $num_pages; $i++) {
+			for($i = 0; $i < $total_pages; $i++) {
 				$page = wp_xmlrpc_server::wp_getPage(array(
 					$blog_id, $pages[$i]->ID, $username, $password
 				));
