Showing content from https://gitlab.com/OldManProgrammer/unix-tree/-/merge_requests/8.patch below:
From 271f02b1c7fa2c44b1118f078077101c7b27dbeb Mon Sep 17 00:00:00 2001 From: Kenta11 <9071830+Kenta11@users.noreply.github.com> Date: Sat, 19 Nov 2022 01:15:02 +0900 Subject: [PATCH] fix the bug and add a NULL guard --- json.c | 6 ++++-- xml.c | 16 ++++------------ 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/json.c b/json.c index c88bf37..a589f96 100644 --- a/json.c +++ b/json.c @@ -120,8 +120,10 @@ int json_printinfo(char *dirname, struct _info *file, int level) if (!noindent) json_indent(level); - if (file->lnk) mt = file->mode & S_IFMT; - else mt = file->mode & S_IFMT; + if (file != NULL) { + if (file->lnk) mt = file->mode & S_IFMT; + else mt = file->mode & S_IFMT; + } else mt = 0; for(t=0;ifmt[t];t++) if (ifmt[t] == mt) break; diff --git a/xml.c b/xml.c index e8d1e61..3b0d9b2 100644 --- a/xml.c +++ b/xml.c @@ -104,8 +104,10 @@ int xml_printinfo(char *dirname, struct _info *file, int level) if (!noindent) xml_indent(level); - if (file->lnk) mt = file->mode & S_IFMT; - else mt = file->mode & S_IFMT; + if (file != NULL) { + if (file->lnk) mt = file->mode & S_IFMT; + else mt = file->mode & S_IFMT; + } else mt = 0; for(t=0;ifmt[t];t++) if (ifmt[t] == mt) break; @@ -116,16 +118,6 @@ int xml_printinfo(char *dirname, struct _info *file, int level) int xml_printfile(char *dirname, char *filename, struct _info *file, int descend) { - int t, mt; - - if (file) { - if (file->lnk) mt = file->mode & S_IFMT; - else mt = file->mode & S_IFMT; - } else mt = 0; - for(t=0;ifmt[t];t++) - if (ifmt[t] == mt) break; - fprintf(outfile,"<%s", ftype[t]); - fprintf(outfile, " name=\""); html_encode(outfile, filename); fputc('"',outfile); -- GitLab
RetroSearch is an open source project built by @garambo
| Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4