Don't forget to do null pointer checking before trying to

dereference them.
This commit is contained in:
David Parsons
2008-01-03 22:20:54 -08:00
parent ad6186467c
commit 1d9d6da4c8
5 changed files with 132 additions and 15 deletions
+3 -1
View File
@@ -758,7 +758,7 @@ static Paragraph *display(Paragraph*, MMIOT*, int);
static void
emit(Paragraph *p, MMIOT *f)
{
int multiple = ( p->next != 0 );
int multiple = p && p->next;
while (( p = display(p, f, multiple) ))
;
@@ -790,6 +790,8 @@ listdisplay(Paragraph *p, MMIOT* f)
static Paragraph*
display(Paragraph *p, MMIOT *f, int multiple)
{
if ( !p ) return;
switch ( p->typ ) {
case FORCED:
break;
+27
View File
@@ -0,0 +1,27 @@
echo "crashes"
rc=0
echo -n ' hanging quote in list ............ '
./markdown >/dev/null 2>/dev/null << EOF
* > this should not die
no.
EOF
if [ "$?" -eq 0 ]; then
echo "OK"
else
echo "Failed"
rc=1
fi
echo -n ' dangling list item ............... '
if echo ' - ' | ./markdown >/dev/null 2>/dev/null; then
echo "OK"
else
echo "Failed"
rc=1
fi
-10
View File
@@ -1,10 +0,0 @@
echo -n "quote................................"
exec 2> /dev/null
if ./markdown tests/quote.text >/dev/null; then
echo "OK"
exit 0
fi
echo "FAILED"
exit 1
-4
View File
@@ -1,4 +0,0 @@
1. > this is a test
And this is not a test.
+102
View File
@@ -0,0 +1,102 @@
echo "smarty pants"
rc=0
echo -n ' (c) -> &copy; .................... '
if echo '(c)' | ./markdown | grep '&copy;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' (r) -> &reg; ..................... '
if echo '(r)' | ./markdown | grep '&reg;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' (tm) -> &trade; .................. '
if echo '(tm)' | ./markdown | grep '&trade;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' ... -> &hellip; .................. '
if echo '...' | ./markdown | grep '&hellip;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' -- -> &mdash; .................... '
if echo '--' | ./markdown | grep '&mdash;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' - -> &ndash; ..................... '
if echo 'regular - ' | ./markdown | grep '&ndash;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' A-B -> A-B ....................... '
if echo 'A-B' | ./markdown | grep '&ndash;' >/dev/null; then
echo "FAILED"
rc=1
else
echo "OK"
fi
echo -n ' "fancy" -> &ldquo;fancy&rdquo; ... '
if echo '"fancy"' | ./markdown | grep '&ldquo;fancy&rdquo;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' '"'fancy'"' -> &lsquo;fancy&rsquo; ... '
if echo "'fancy'" | ./markdown | grep '&lsquo;fancy&rsquo;' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n " don't -> don't ................... "
if echo "don't" | ./markdown | grep "don't" >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi
echo -n ' `` ` `` -> <code> ` </code> ...... '
if echo '`` ` ``' | ./markdown | grep '<code> ` </code>' >/dev/null; then
echo "OK"
else
echo "FAILED"
rc=1
fi