Browse code

bb12005: fixing memory leak in htmlnorm code.

Micah Snyder authored on 2018/03/09 02:19:48
Showing 1 changed files
... ...
@@ -1852,7 +1852,7 @@ int html_normalise_map(fmap_t *map, const char *dirname, tag_arguments_t *hrefs,
1852 1852
 int html_screnc_decode(fmap_t *map, const char *dirname)
1853 1853
 {
1854 1854
 	int count, retval=FALSE;
1855
-	unsigned char *line, tmpstr[6];
1855
+	unsigned char *line = NULL, tmpstr[6];
1856 1856
 	unsigned char *ptr, filename[1024];
1857 1857
 	int ofd;
1858 1858
 	struct screnc_state screnc_state;
... ...
@@ -1877,7 +1877,8 @@ int html_screnc_decode(fmap_t *map, const char *dirname)
1877 1877
 			break;
1878 1878
 		}
1879 1879
 		free(line);
1880
-        }
1880
+		line = NULL;
1881
+	}
1881 1882
 	if (!line) {
1882 1883
 		goto abort;
1883 1884
 	}
... ...
@@ -1914,6 +1915,7 @@ int html_screnc_decode(fmap_t *map, const char *dirname)
1914 1914
 		screnc_decode(ptr, &screnc_state);
1915 1915
 		cli_writen(ofd, ptr, strlen((const char*)ptr));
1916 1916
 		free(line);
1917
+		line = NULL;
1917 1918
 		if (screnc_state.length) {
1918 1919
 			ptr = line = cli_readchunk(NULL, &m_area, 8192);
1919 1920
 		}
... ...
@@ -1925,5 +1927,8 @@ int html_screnc_decode(fmap_t *map, const char *dirname)
1925 1925
 
1926 1926
 abort:
1927 1927
 	close(ofd);
1928
+	if (line) {
1929
+		free(line);
1930
+	}
1928 1931
 	return retval;
1929 1932
 }