another libnhmain.c follow-up

Check if it's available before calling.
This commit is contained in:
nhmall
2026-05-03 14:11:47 -04:00
parent b6482d09f4
commit b92c1483bb
+9 -3
View File
@@ -804,15 +804,21 @@ get_nhuuid(void)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
char *uuid = (char *) &stmp[0]; char *uuid = (char *) &stmp[0];
int uuid_available = 0;
if (svn.nhuuid[0]) if (svn.nhuuid[0])
return; return;
#ifndef NONHUUID #ifndef NONHUUID
#ifdef NHUUID #ifdef NHUUID
uuid = emscripten_run_script_string("crypto.randomUUID()"); uuid_available = emscripten_run_script_int(
if (!uuid) { "typeof crypto !== 'undefined'"
uuid = (char *) &stmp[0]; " && typeof crypto.randomUUID === 'function'");
if (uuid_available) {
uuid = emscripten_run_script_string("crypto.randomUUID()");
if (!uuid) {
uuid = (char *) &stmp[0];
}
} }
#endif /* NHUUID */ #endif /* NHUUID */
#endif /* NONHUUID */ #endif /* NONHUUID */