From a018e5b8b28bceca42f5f2b30515e5fa0d7b91dc Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Sun, 5 May 2019 11:12:49 +0000
Subject: [PATCH] Added NULL pointer (strdup failure) check for good measure.

---
 src/smblib/smbtxt.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/src/smblib/smbtxt.c b/src/smblib/smbtxt.c
index 51209dfbb0..1170ce84d8 100644
--- a/src/smblib/smbtxt.c
+++ b/src/smblib/smbtxt.c
@@ -341,13 +341,14 @@ void SMBCALL smb_parse_content_type(const char* content_type, char** subtype, ch
 	if((p = strstr(buf, "text/")) == buf) {
 		p += 5;
 		if(subtype != NULL) {
-			*subtype = strdup(p);
-			char* tp = *subtype;
-			FIND_WHITESPACE(tp);
-			*tp = 0;
-			tp = *subtype;
-			FIND_CHAR(tp, ';');
-			*tp = 0;
+			if((*subtype = strdup(p)) != NULL) {
+				char* tp = *subtype;
+				FIND_WHITESPACE(tp);
+				*tp = 0;
+				tp = *subtype;
+				FIND_CHAR(tp, ';');
+				*tp = 0;
+			}
 		}
 		if(charset != NULL && (p = strstr(p, "charset=")) != NULL) {
 			p += 8;
-- 
GitLab