Index: wp-includes/link-template.php
===================================================================
--- wp-includes/link-template.php	(revision 24175)
+++ wp-includes/link-template.php	(working copy)
@@ -302,23 +302,31 @@
 
 	$post = get_post( $post );
 
+	if ( empty( $post ) )
+		return null;
+
 	if ( $wp_rewrite->using_permalinks() && ( $post->post_parent > 0 ) && ( $post->post_parent != $post->ID ) ) {
-		$parent = get_post($post->post_parent);
+		$parent = get_post( $post->post_parent );
+
+	if ( ! empty( $parent ) ) {
 		if ( 'page' == $parent->post_type )
 			$parentlink = _get_page_link( $post->post_parent ); // Ignores page_on_front
 		else
 			$parentlink = get_permalink( $post->post_parent );
 
-		if ( is_numeric($post->post_name) || false !== strpos(get_option('permalink_structure'), '%category%') )
+		if ( is_numeric( $post->post_name ) || false !== strpos( get_option( 'permalink_structure' ), '%category%' ) )
 			$name = 'attachment/' . $post->post_name; // <permalink>/<int>/ is paged so we use the explicit attachment marker
 		else
 			$name = $post->post_name;
 
-		if ( strpos($parentlink, '?') === false )
-			$link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
+		if ( strpos( $parentlink, '?' ) === false )
+			$link = user_trailingslashit( trailingslashit( $parentlink ) . '%postname%' );
 
 		if ( ! $leavename )
 			$link = str_replace( '%postname%', $name, $link );
+
+		}
+
 	}
 
 	if ( ! $link )
Index: wp-admin/includes/class-wp-media-list-table.php
===================================================================
--- wp-admin/includes/class-wp-media-list-table.php	(revision 24175)
+++ wp-admin/includes/class-wp-media-list-table.php	(working copy)
@@ -302,7 +302,7 @@
 		break;
 
 	case 'parent':
-		if ( $post->post_parent > 0 ) {
+		if ( $post->post_parent > 0 && get_post( $post->post_parent ) ) {
 			if ( get_post( $post->post_parent ) ) {
 				$title =_draft_or_post_title( $post->post_parent );
 			}
