Browse code

Fixed memory leak reported by oss-fuzz.

Andy Ragusa (aragusa) authored on 2020/02/01 03:31:31
Showing 1 changed files
... ...
@@ -955,6 +955,7 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first
955 955
 
956 956
                         totalHeaderCnt++;
957 957
                         if (haveTooManyEmailHeaders(totalHeaderCnt, ctx, heuristicFound)) {
958
+                            DO_FREE(header);
958 959
                             break;
959 960
                         }
960 961
                         needContinue = (parseEmailHeader(ret, header, rfc821, ctx, heuristicFound) < 0);
... ...
@@ -1067,6 +1068,8 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first
1067 1067
                 {
1068 1068
                     char *header     = getMallocedBufferFromList(head); /*This is the issue */
1069 1069
                     int needContinue = 0;
1070
+                    DO_VERIFY_POINTER(header);
1071
+
1070 1072
                     needContinue     = (header[strlen(header) - 1] == ';');
1071 1073
                     if (0 == needContinue) {
1072 1074
                         needContinue = (line && (count_quotes(header) & 1));
... ...
@@ -1075,6 +1078,7 @@ parseEmailFile(fmap_t *map, size_t *at, const table_t *rfc821, const char *first
1075 1075
                     if (0 == needContinue) {
1076 1076
                         totalHeaderCnt++;
1077 1077
                         if (haveTooManyEmailHeaders(totalHeaderCnt, ctx, heuristicFound)) {
1078
+                            DO_FREE(header);
1078 1079
                             break;
1079 1080
                         }
1080 1081
                         needContinue = (parseEmailHeader(ret, header, rfc821, ctx, heuristicFound) < 0);