]> granicus.if.org Git - multimarkdown/commitdiff
FIXED: Add NULL check on my strdup functions
authorFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 23 Sep 2017 01:09:42 +0000 (21:09 -0400)
committerFletcher T. Penney <fletcher@fletcherpenney.net>
Sat, 23 Sep 2017 01:09:42 +0000 (21:09 -0400)
Sources/libMultiMarkdown/epub.c
Sources/libMultiMarkdown/fodt.c
Sources/libMultiMarkdown/html.c
Sources/libMultiMarkdown/latex.c
Sources/libMultiMarkdown/mmd.c
Sources/libMultiMarkdown/opendocument-content.c
Sources/libMultiMarkdown/opendocument.c
Sources/libMultiMarkdown/transclude.c
Sources/libMultiMarkdown/writer.c
Sources/multimarkdown/main.c

index 495eb2246df5dabce179fae2d512342bf5b0ec50..d878599b70891d645a74475f109627631818b00c 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index ebfd32fa99bbbdd191279d9cf792333e2849c85e..51581746e9374b3f850d461ccb4c393d2e9c3343 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index 740dd431d00bce6243bbd0cca9d256f0c1c8b475..156f333f24a90fbea00a99922b810c7b0cf46072 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index 3858d645e73ffb305a30027df26eae301eec96d5..6b31942b35fb83ec553747e049958da299ab0089 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index 830d6157b1cd06986bffc80135b57794600cca76..c1e8259d32bc6ad2c6d7fadd6a2385c7f524a5e5 100644 (file)
@@ -86,6 +86,10 @@ void mmd_pair_tokens_in_block(token * block, token_pair_engine * e, stack * s);
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index 595fb45b4b03fd29166ef9f4fffb2ddc1804c1ca..467c6301779fcc2e5ee072fcf2897b5309ad39c2 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index 49ad763a7d2f8d6a71303fc2fab7a707c9f1110c..5ea74af8b20d735665c36ce5c73a06797f57e20b 100644 (file)
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index fa473ab3a109094537946b2a936ed7b6536dbd2a..8f4942fb599681d5673c7221a852ef8fb88c6a6d 100644 (file)
 
 /// strndup not available on all platforms
 static char * my_strndup(const char * source, size_t n) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        size_t len = 0;
        char * result;
        const char * test = source;
index e6d9c558e3dc49126c0ac3e873f6a11f7c8033c1..d1087f69a2d639c91ac8c57e94643751a3f74d8c 100644 (file)
@@ -91,6 +91,10 @@ void store_abbreviation(scratch_pad * scratch, footnote * a);
 
 /// strndup not available on all platforms
 static char * my_strndup(const char * source, size_t n) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        size_t len = 0;
        char * result;
        const char * test = source;
@@ -117,6 +121,10 @@ static char * my_strndup(const char * source, size_t n) {
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {
index fe4a36a772e7339b0f969cdb158a8ffd03e858fb..9797ec4933f6737f0dd2dd6356bbe27884724bfb 100644 (file)
@@ -84,6 +84,10 @@ struct arg_rem *a_rem1, *a_rem2, *a_rem3, *a_rem4, *a_rem5, *a_rem6;
 
 /// strdup() not available on all platforms
 static char * my_strdup(const char * source) {
+       if (source == NULL) {
+               return NULL;
+       }
+
        char * result = malloc(strlen(source) + 1);
 
        if (result) {