~rabbits/public-inbox

Fix segmentation fault on first boot. v1 APPLIED

james palmer: 3
 Fix segmentation fault on first boot.
 Fix typo in Uxn11 usage message. It is no-longer uxncli.
 Show rom name in window title.

 3 files changed, 5 insertions(+), 3 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~rabbits/public-inbox/patches/31037/mbox | git am -3
Learn more about email & git

[PATCH 1/3] Fix segmentation fault on first boot. Export this patch

When emu_start() is first called, the Uxn struct is uninitialised stack data.
This meant the u->ram pointer would be an invalid address so the program would crash
with a segmentation fault when attempting to free it. By setting it to NULL, we avoid this
because calling free() on a NULL pointer is a no-op.
---
 src/uxn11.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/uxn11.c b/src/uxn11.c
index 15adf5d..f2cda7f 100644
--- a/src/uxn11.c
+++ b/src/uxn11.c
@@ -227,6 +227,7 @@ main(int argc, char **argv)
	if(argc < 2)
		return emu_error("Usage", "uxncli game.rom args");
	/* start sequence */
	u.ram = NULL;
	if(!emu_start(&u, argv[1]))
		return emu_error("Start", "Failed");
	if(!init())
-- 
2.35.1

[PATCH 2/3] Fix typo in Uxn11 usage message. It is no-longer uxncli. Export this patch

---
 src/uxn11.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/uxn11.c b/src/uxn11.c
index f2cda7f..c8d60b1 100644
--- a/src/uxn11.c
+++ b/src/uxn11.c
@@ -225,7 +225,7 @@ main(int argc, char **argv)
	struct pollfd fds[2];
	static const struct itimerspec screen_tspec = {{0, 16666666}, {0, 16666666}};
	if(argc < 2)
		return emu_error("Usage", "uxncli game.rom args");
		return emu_error("Usage", "uxn11 game.rom args");
	/* start sequence */
	u.ram = NULL;
	if(!emu_start(&u, argv[1]))
-- 
2.35.1

[PATCH 3/3] Show rom name in window title. Export this patch

---
 src/uxn11.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/uxn11.c b/src/uxn11.c
index c8d60b1..e68300f 100644
--- a/src/uxn11.c
+++ b/src/uxn11.c
@@ -199,7 +199,7 @@ emu_event(Uxn *u)
}

static int
init(void)
init(char *title)
{
	Atom wmDelete;
	display = XOpenDisplay(NULL);
@@ -210,6 +210,7 @@ init(void)
	XSelectInput(display, window, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | ExposureMask | KeyPressMask | KeyReleaseMask);
	wmDelete = XInternAtom(display, "WM_DELETE_WINDOW", True);
	XSetWMProtocols(display, window, &wmDelete, 1);
	XStoreName(display, window, title);
	XMapWindow(display, window);
	ximage = XCreateImage(display, visual, DefaultDepth(display, DefaultScreen(display)), ZPixmap, 0, (char *)uxn_screen.pixels, uxn_screen.width, uxn_screen.height, 32, 0);
	hide_cursor();
@@ -230,7 +231,7 @@ main(int argc, char **argv)
	u.ram = NULL;
	if(!emu_start(&u, argv[1]))
		return emu_error("Start", "Failed");
	if(!init())
	if(!init(argv[1]))
		return emu_error("Init", "Failed");
	/* console vector */
	for(i = 2; i < argc; i++) {
-- 
2.35.1