code that would crash ESP32

This commit is contained in:
folkert van heusden 2023-03-17 21:17:16 +01:00
parent e9284e1914
commit 0dda33c754
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1

View file

@ -60,11 +60,11 @@ void dolog(const log_level_t ll, const char *fmt, ...)
return;
if (!lfh) {
#if !defined(ESP32)
lfh = fopen(logfile, "a+");
if (!lfh)
error_exit(true, "Cannot access log-file %s", logfile);
#if !defined(ESP32)
if (lf_uid != -1 && fchown(fileno(lfh), lf_uid, lf_gid) == -1)
error_exit(true, "Cannot change logfile (%s) ownership", logfile);
@ -95,8 +95,10 @@ void dolog(const log_level_t ll, const char *fmt, ...)
(void)vasprintf(&str, fmt, ap);
va_end(ap);
#if !defined(ESP32)
if (ll >= log_level_file)
fprintf(lfh, "%s%s\n", ts_str, str);
#endif
if (ll >= log_level_screen)
printf("%s%s\r\n", ts_str, str);