]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Fix memory leaks etc
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Fri, 17 Feb 2017 00:48:36 +0000 (19:48 -0500)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Fri, 17 Feb 2017 00:48:36 +0000 (19:48 -0500)
src/beamer.c
src/latex.c
src/memoir.c
src/mmd.c
src/scanners.c
src/scanners.re
src/writer.c

index 656fed23e52eb6cd8521ffca69ed722495c28db7..4bc61575dfa1b71059fbdd5e878749a14603929b 100644 (file)
@@ -76,6 +76,7 @@ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratc
                                break;
                        case BLOCK_SETEXT_2:
                                level = 2;
+                               break;
                        default:
                                level = 1 + current->type - BLOCK_H1;
                }
@@ -95,6 +96,7 @@ void mmd_outline_add_beamer(DString * out, token * current, scratch_pad * scratc
                                        break;
                                case BLOCK_SETEXT_2:
                                        t_level = 2;
+                                       break;
                                default:
                                        t_level = 1 + t->type - BLOCK_H1;
                        }
@@ -149,14 +151,8 @@ void mmd_export_token_beamer(DString * out, const char * source, token * t, scra
                return;
 
        short   temp_short;
-       short   temp_short2;
-       link *  temp_link       = NULL;
        char *  temp_char       = NULL;
-       char *  temp_char2      = NULL;
-       char *  temp_char3      = NULL;
-       bool    temp_bool       = 0;
        token * temp_token      = NULL;
-       footnote * temp_note = NULL;
 
        switch (t->type) {
                case DOC_START_TOKEN:
@@ -290,7 +286,6 @@ void mmd_export_citation_list_beamer(DString * out, const char * source, scratch
                        pad(out, 2, scratch);
 
                        note = stack_peek_index(scratch->used_citations, i);
-                       content = note->content;
 
                        printf("\\bibitem{%s}\n", note->label_text);
                        scratch->padded = 6;
index 0d00a2ab64b721bfbbd63a1778fb2a4ca2fc35cd..ac8d28db4d5766e18e596a4e85fa55046ddfc1fd 100644 (file)
@@ -204,7 +204,6 @@ void mmd_print_localized_char_latex(DString * out, unsigned short type, scratch_
 
 
 void mmd_export_link_latex(DString * out, const char * source, token * text, link * link, scratch_pad * scratch) {
-       attr * a = link->attributes;
        char * temp_char;
 
        if (link->url) {
@@ -234,21 +233,6 @@ void mmd_export_link_latex(DString * out, const char * source, token * text, lin
        } else
                print("\\href{}");
 
-//     if (link->title && link->title[0] != '\0') {
-//             print(" title=\"");
-//             mmd_print_string_latex(out, link->title);
-//             print("\"");
-//     }
-
-//     while (a) {
-//             print(" ");
-//             print(a->key);
-//             print("=\"");
-//             print(a->value);
-//             print("\"");
-//             a = a->next;
-//     }
-
        print("{");
 
        // If we're printing contents of bracket as text, then ensure we include it all
@@ -1367,10 +1351,10 @@ void mmd_export_token_latex(DString * out, const char * source, token * t, scrat
                        if (t->next && t->next->type == TABLE_DIVIDER) {
                                t = t->next;
 
-                               if (t->next && t->next->type == TABLE_CELL)
+                               if (t->next && t->next->type == TABLE_CELL) {
                                        print("&");
-
-                               scratch->table_cell_count += t->next->len;
+                                       scratch->table_cell_count += t->next->len;
+                               }
                        } else
                                scratch->table_cell_count++;
 
@@ -1669,7 +1653,6 @@ void mmd_export_citation_list_latex(DString * out, const char * source, scratch_
 
                        scratch->footnote_para_counter = 0;
 
-                       content = note->content;
                        scratch->citation_being_printed = i + 1;
 
                        mmd_export_token_tree_latex(out, source, content, scratch);
index 841cee1bcbcde5a9c95553c7326747d0f888e6b5..2416619dc5123fb31b60a427d8224283c406b78c 100644 (file)
@@ -67,15 +67,7 @@ void mmd_export_token_memoir(DString * out, const char * source, token * t, scra
        if (t == NULL)
                return;
 
-       short   temp_short;
-       short   temp_short2;
-       link *  temp_link       = NULL;
        char *  temp_char       = NULL;
-       char *  temp_char2      = NULL;
-       char *  temp_char3      = NULL;
-       bool    temp_bool       = 0;
-       token * temp_token      = NULL;
-       footnote * temp_note = NULL;
 
        switch (t->type) {
                case DOC_START_TOKEN:
index 5137ac1e68733dd6ffdcd9e89d6c038f9091c5af..e08948bf4a652ba97994fa4188020be9bb5f3e0b 100644 (file)
--- a/src/mmd.c
+++ b/src/mmd.c
@@ -1693,7 +1693,6 @@ void strip_line_tokens_from_block(mmd_engine * e, token * block) {
                                        goto handle_line;
                                }
                        default:
-                               handle_block:
                                //fprintf(stderr, "Unspecified line type %d inside block type %d\n", l->type, block->type);
                                // This is a block, need to remove it from chain and
                                // Add to parent
index 38de8202d16f49ff875a3357322467a2fbbd867a..d80a3869fea1a3d9591e770b4916820b5006d106 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 0.14.3 on Mon Feb 13 09:48:30 2017 */
+/* Generated by re2c 0.14.3 on Thu Feb 16 19:37:08 2017 */
 /**
 
        MultiMarkdown 6 -- Lightweight markup processor to produce HTML, LaTeX, and more.
@@ -8876,7 +8876,6 @@ yy650:
 
 
 size_t scan_meta_key(const char * c) {
-       const char * marker = NULL;
        const char * start = c;
 
 
@@ -9489,7 +9488,6 @@ yy734:
 
 
 size_t scan_destination(const char * c) {
-       const char * marker = NULL;
        const char * start = c;
 
 
index 0b615321357f50d4799dabd393f7f4d1b72b5a83..ad1d27402b196508981131231e5bbd6244c0e09a 100644 (file)
@@ -353,7 +353,6 @@ size_t scan_meta_line(const char * c) {
 
 
 size_t scan_meta_key(const char * c) {
-       const char * marker = NULL;
        const char * start = c;
 
 /*!re2c
@@ -403,7 +402,6 @@ size_t scan_alignment_string(const char * c) {
 
 
 size_t scan_destination(const char * c) {
-       const char * marker = NULL;
        const char * start = c;
 
 /*!re2c
index b96dcd7ba31d8558be67fc719731c6db5b1d0c90..f041e7f68e29fc1fcc590bba5fec9b2a8bf530ef 100644 (file)
@@ -258,11 +258,12 @@ char * text_inside_pair(const char * source, token * pair) {
        char * result = NULL;
 
        if (source && pair) {
-               if (pair->child->mate) {
+               if (pair->child && pair->child->mate) {
                        // [foo], [^foo], [#foo] should give different strings -- use closer len
                        result = strndup(&source[pair->start + pair->child->mate->len], pair->len - (pair->child->mate->len * 2));
                } else {
-                       result = strndup(&source[pair->start + pair->child->len], pair->len - (pair->child->len + 1));
+                       if (pair->child)
+                               result = strndup(&source[pair->start + pair->child->len], pair->len - (pair->child->len + 1));
                }
        }
 
@@ -1454,9 +1455,13 @@ void parse_brackets(const char * source, scratch_pad * scratch, token * bracket,
 
        if (temp_link) {
                // Don't output brackets
-               bracket->child->type = TEXT_EMPTY;
-               bracket->child->mate->type = TEXT_EMPTY;
-
+               if (bracket->child) {
+                       bracket->child->type = TEXT_EMPTY;
+               
+                       if (bracket->child->mate)
+                               bracket->child->mate->type = TEXT_EMPTY;
+               }
+               
                *final_link = temp_link;
 
                // Skip over second bracket if present
@@ -1707,7 +1712,7 @@ bool table_has_caption(token * t) {
                                (t->next->type == TEXT_LINEBREAK)))
                                t = t->next;
 
-                       if (t->next == NULL)
+                       if (t && t->next == NULL)
                                return true;
                }
        }