Browse code

tls: free temporary buffer when fixing shm path name for config

Daniel-Constantin Mierla authored on 20/07/2017 07:25:20
Showing 1 changed files
... ...
@@ -480,16 +480,25 @@ static int tls_foreach_CTX_in_cfg(tls_domains_cfg_t* cfg,
480 480
 int fix_shm_pathname(str* path)
481 481
 {
482 482
 	str new_path;
483
-	char* abs_path;
484
-	
485
-	if (path->s && path->len && *path->s != '.' && *path->s != '/') {
483
+	char *abs_path;
484
+
485
+	if(path->s && path->len && *path->s != '.' && *path->s != '/') {
486 486
 		abs_path = get_abs_pathname(0, path);
487
-		if (abs_path == 0) return -1;
487
+		if(abs_path == 0) {
488
+			LM_ERR("get abs pathname failed\n");
489
+			return -1;
490
+		}
488 491
 		new_path.len = strlen(abs_path);
489 492
 		new_path.s = shm_malloc(new_path.len + 1);
493
+		if(new_path.s == 0) {
494
+			LM_ERR("no more shm memory\n");
495
+			pkg_free(abs_path);
496
+			return -1;
497
+		}
490 498
 		memcpy(new_path.s, abs_path, new_path.len);
491 499
 		new_path.s[new_path.len] = 0;
492 500
 		shm_free(path->s);
501
+		pkg_free(abs_path);
493 502
 		*path = new_path;
494 503
 	}
495 504
 	return 0;