Commit 8ba5f851 authored by Cosimo Cecchi's avatar Cosimo Cecchi

Merge branch '134-dump-heap-error-check' into 'master'

Fix missing error check in dumpHeap()

Closes #134

See merge request !277
parents bc30b51b 2fb9c043
Pipeline #67819 passed with stages
in 9 minutes and 56 seconds
......@@ -28,3 +28,9 @@ describe('System.gc()', function () {
expect(System.gc).not.toThrow();
});
});
describe('System.dumpHeap()', function () {
it('throws but does not crash when given a nonexistent path', function () {
expect(() => System.dumpHeap('/does/not/exist')).toThrow();
});
});
\ No newline at end of file
......@@ -24,6 +24,8 @@
#include <config.h>
#include <errno.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
......@@ -106,6 +108,11 @@ gjs_dump_heap(JSContext *cx,
if (filename) {
FILE *fp = fopen(filename, "a");
if (!fp) {
gjs_throw(cx, "Cannot dump heap to %s: %s", filename.get(),
strerror(errno));
return false;
}
js::DumpHeap(cx, fp, js::IgnoreNurseryObjects);
fclose(fp);
} else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment