Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save reklis/2002442 to your computer and use it in GitHub Desktop.
Save reklis/2002442 to your computer and use it in GitHub Desktop.
discount-null-pointer-dereference-fixes-no-whitespace.diff
diff --git a/generate.c b/generate.c
index 8e82afd..f3a1bd9 100644
--- a/generate.c
+++ b/generate.c
@@ -652,6 +652,7 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
if ( f->flags & IS_LABEL )
___mkd_reparse(T(text), S(text), tag->flags, f, 0);
else if ( tag->link_pfx ) {
+ if (ref) {
printlinkyref(f, tag, T(ref->link), S(ref->link));
if ( tag->WxH ) {
@@ -669,7 +670,8 @@ linkyformat(MMIOT *f, Cstring text, int image, Footnote *ref)
___mkd_reparse(T(text), S(text), tag->flags, f, 0);
Qstring(tag->text_sfx, f);
}
- else
+ }
+ else if (ref)
Qwrite(T(ref->link) + tag->szpat, S(ref->link) - tag->szpat, f);
return 1;
diff --git a/markdown.c b/markdown.c
index 99acc60..d01d5dc 100644
--- a/markdown.c
+++ b/markdown.c
@@ -784,6 +784,8 @@ quoteblock(Paragraph *p, DWORD flags)
int i;
q = p->text;
+
+ if (q) {
p->text = p->text->next;
if ( (i = szmarkerclass(1+T(q->text))) == 3 )
@@ -796,6 +798,7 @@ quoteblock(Paragraph *p, DWORD flags)
___mkd_freeLine(q);
}
+ };
return t;
}
@@ -1169,6 +1172,7 @@ actually_a_table(MMIOT *f, Line *pp)
/* second line must be only whitespace, -, |, or : */
r = pp->next;
+ if (r) {
for ( j=r->dle; j < S(r->text); ++j ) {
c = T(r->text)[j];
@@ -1176,6 +1180,7 @@ actually_a_table(MMIOT *f, Line *pp)
return 0;
}
}
+ }
return 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment