Fix segfault when replicant source can't be found

This commit is contained in:
Sasha Koshka 2023-11-14 01:05:20 -05:00
parent 192aa666ca
commit 0e99b0ceed
3 changed files with 9 additions and 4 deletions

View File

@ -105,7 +105,7 @@ String XmdReplicantResolveName (ConstString rawName) {
String name = NULL; String name = NULL;
XtAsprintf(&name, "%s.so", rawName); XtAsprintf(&name, "%s.so", rawName);
if (list == NULL) list = defaultReplicantPath; if (list == NULL) list = defaultReplicantPath;
while (file == NULL) { while (file == NULL) {
char ch = *list; char ch = *list;
if (dirBuffer == NULL) dirBuffer = XmdBufferNew(char); if (dirBuffer == NULL) dirBuffer = XmdBufferNew(char);
@ -120,6 +120,7 @@ String XmdReplicantResolveName (ConstString rawName) {
} else { } else {
XmdBufferPush(dirBuffer, &ch); XmdBufferPush(dirBuffer, &ch);
} }
if (ch == 0) break;
list ++; list ++;
} }
XtFree(name); XtFree(name);
@ -355,7 +356,9 @@ static replicantSource *sourceGet (ConstString name) {
if (source != NULL) return source; if (source != NULL) return source;
/* open the source */ /* open the source */
return sourceOpen(name); source = sourceOpen(name);
XmdStringMapSet(resident, name, source);
return source;
} }
static String scanDir (ConstString path, ConstString name) { static String scanDir (ConstString path, ConstString name) {

View File

@ -50,8 +50,9 @@ void handleDestroyFreePixmap (
Widget Launcher_XmdReplicantCreate ( Widget Launcher_XmdReplicantCreate (
XtAppContext application, XtAppContext application,
Widget parent, Widget parent,
XmdReplicantState *state, XmdReplicantState *state
) { ) {
(void)(application);
String iconName = XmdReplicantStateQuery(state, "Icon"); String iconName = XmdReplicantStateQuery(state, "Icon");
Pixmap icon; Pixmap icon;
#define iconCase(name) if (strcmp(#name, iconName) == 0) {\ #define iconCase(name) if (strcmp(#name, iconName) == 0) {\

View File

@ -65,7 +65,8 @@ static void loadReplicants (Widget parent) {
XtAsprintf ( XtAsprintf (
&fullName, "%s/%s", &fullName, "%s/%s",
replicantsDir, entry->d_name); replicantsDir, entry->d_name);
XmdReplicantOpen(parent, fullName); XmdReplicantOpen (
application, parent, fullName);
XtFree(fullName); XtFree(fullName);
} }
} }