Diff of /libopagent/opagent.c [ecfbcc] .. [74abfb]  Maximize  Restore

Switch to side-by-side view

--- a/libopagent/opagent.c
+++ b/libopagent/opagent.c
@@ -168,10 +168,13 @@
 	dumpfile = fdopen(fd, "w");
 	if (!dumpfile) {
 		fprintf(stderr, "%s\n", err_msg);
-		return NULL;
-	}
-	if (define_bfd_vars())
-		return NULL;
+		close(fd);
+		return NULL;
+	}
+	if (define_bfd_vars()) {
+		fclose(dumpfile);
+		return NULL;
+	}
 	header.magic = JITHEADER_MAGIC;
 	header.version = JITHEADER_VERSION;
 	header.totalsize = sizeof(header) + strlen(_bfd_target_name) + 1;
@@ -181,6 +184,7 @@
 	header.bfd_arch = _bfd_arch;
 	header.bfd_mach = _bfd_mach;
 	if (gettimeofday(&tv, NULL)) {
+		fclose(dumpfile);
 		fprintf(stderr, "gettimeofday failed\n");
 		return NULL;
 	}
@@ -188,16 +192,19 @@
 	header.timestamp = tv.tv_sec;
 	snprintf(err_msg, PATH_MAX + 16, "Error writing to %s", dump_path);
 	if (!fwrite(&header, sizeof(header), 1, dumpfile)) {
+		fclose(dumpfile);
 		fprintf(stderr, "%s\n", err_msg);
 		return NULL;
 	}
 	if (!fwrite(_bfd_target_name, strlen(_bfd_target_name) + 1, 1,
 		    dumpfile)) {
+		fclose(dumpfile);
 		fprintf(stderr, "%s\n", err_msg);
 		return NULL;
 	}
 	/* write padding '\0' if necessary */
 	if (pad_cnt && !fwrite(pad_bytes, pad_cnt, 1, dumpfile)) {
+		fclose(dumpfile);
 		fprintf(stderr, "%s\n", err_msg);
 		return NULL;
 	}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks