]> git.lizzy.rs Git - rust.git/commitdiff
rustdoc: Prevent a segfault when using markdown
authorAlex Crichton <alex@alexcrichton.com>
Sat, 24 May 2014 02:32:18 +0000 (19:32 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sun, 25 May 2014 08:18:11 +0000 (01:18 -0700)
The field passed from markdown could sometimes be null, and it wasn't properly
handled.

src/librustdoc/html/markdown.rs

index 7b8514ab38f621c14d8ba503ab6de7fd5fe3cd27..f49b7f3e9890305daf71530384d89dee440ff27b 100644 (file)
@@ -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| {