From a96067077a7536f80e131deaf3355c30ba8f3bff Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 23 May 2014 19:32:18 -0700 Subject: [PATCH] rustdoc: Prevent a segfault when using markdown The field passed from markdown could sometimes be null, and it wasn't properly handled. --- src/librustdoc/html/markdown.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs index 7b8514ab38f..f49b7f3e989 100644 --- a/src/librustdoc/html/markdown.rs +++ b/src/librustdoc/html/markdown.rs @@ -144,6 +144,8 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result { extern fn block(ob: *mut hoedown_buffer, text: *hoedown_buffer, lang: *hoedown_buffer, opaque: *mut libc::c_void) { unsafe { + if text.is_null() { return } + let opaque = opaque as *mut hoedown_html_renderer_state; let my_opaque: &MyOpaque = &*((*opaque).opaque as *MyOpaque); slice::raw::buf_as_slice((*text).data, (*text).size as uint, |text| {