Index: wp-comments-post.php
===================================================================
--- wp-comments-post.php	(revision 17643)
+++ wp-comments-post.php	(working copy)
@@ -5,9 +5,9 @@
  * @package WordPress
  */
 
-if ( 'POST' != $_SERVER['REQUEST_METHOD'] ) {
+if ( 'POST' !== $_SERVER['REQUEST_METHOD'] ) {
+	header('HTTP/1.1 405 Method Not Allowed');
 	header('Allow: POST');
-	header('HTTP/1.1 405 Method Not Allowed');
 	header('Content-Type: text/plain');
 	exit;
 }
@@ -19,6 +19,9 @@
 
 $comment_post_ID = isset($_POST['comment_post_ID']) ? (int) $_POST['comment_post_ID'] : 0;
 
+if ( $comment_post_ID === 0 )
+	wp_die( __( 'A comment must be associated with a WordPress post id.' ), __( 'Invalid request' ), array( 'response'=>400 ) );
+
 $post = get_post($comment_post_ID);
 
 if ( empty($post->comment_status) ) {
