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
+6
View File
@@ -804,16 +804,22 @@ 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_available = emscripten_run_script_int(
"typeof crypto !== 'undefined'"
" && typeof crypto.randomUUID === 'function'");
if (uuid_available) {
uuid = emscripten_run_script_string("crypto.randomUUID()"); uuid = emscripten_run_script_string("crypto.randomUUID()");
if (!uuid) { if (!uuid) {
uuid = (char *) &stmp[0]; uuid = (char *) &stmp[0];
} }
}
#endif /* NHUUID */ #endif /* NHUUID */
#endif /* NONHUUID */ #endif /* NONHUUID */
Snprintf(svn.nhuuid, sizeof svn.nhuuid, "%s", uuid); Snprintf(svn.nhuuid, sizeof svn.nhuuid, "%s", uuid);