grafx2: include haiku.h in setup.c

the default declaration would convert the returned pointer to int and crash on 64bit
This commit is contained in:
Jerome Duval
2021-03-30 11:47:13 +02:00
parent 3d62d30d14
commit f0dafa02a5

View File

@@ -1,31 +1,45 @@
From b616fdb35baf79ece153b70ca3613d57dee212de Mon Sep 17 00:00:00 2001
From 9df6715c21c6064153a068f11ff008d71615aefc Mon Sep 17 00:00:00 2001
From: Jerome Duval <jerome.duval@gmail.com>
Date: Tue, 30 Mar 2021 10:59:41 +0200
Subject: add checks in Extract_path
Subject: include haiku.h in setup.c
improve haiku_get_app_path()
diff --git a/src/io.c b/src/io.c
index ab64904..30da356 100644
--- a/src/io.c
+++ b/src/io.c
@@ -353,6 +353,17 @@ char * Extract_path(char *dest, const char *source)
char * position;
char * path;
diff --git a/src/haiku.cpp b/src/haiku.cpp
index 708564c..a13e623 100644
--- a/src/haiku.cpp
+++ b/src/haiku.cpp
@@ -63,12 +63,13 @@ char* haiku_get_clipboard()
const char* haiku_get_app_path()
{
static image_info info;
- static int32 cookie = 0;
+ int32 cookie = 0;
+ if (dest == NULL)
+ {
+ GFX2_Log(GFX2_ERROR, "Extract_path() dest is null !\n");
+ return NULL;
+ }
+ if (source == NULL)
+ {
+ GFX2_Log(GFX2_ERROR, "Extract_path() source is null !\n");
+ return NULL;
+ }
+
path = Realpath(source, dest);
if (path == NULL)
{
- if (cookie == 0) do {
- get_next_image_info(B_CURRENT_TEAM, &cookie, &info);
- } while (info.type != B_APP_IMAGE);
+ while (get_next_image_info(B_CURRENT_TEAM, &cookie, &info) == B_OK) {
+ if (info.type == B_APP_IMAGE)
+ return info.name;
+ }
- return info.name;
+ return NULL;
}
#endif
diff --git a/src/setup.c b/src/setup.c
index 3ecb0f6..1a5844c 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -43,6 +43,7 @@
#include <errno.h>
#elif defined(__HAIKU__)
#include <FindDirectory.h>
+ #include "haiku.h"
#endif
#include "struct.h"
--
2.30.0