mirror of https://github.com/omar-polo/gmid.git
some null checks
This commit is contained in:
parent
c4f682f855
commit
caad03081b
8
server.c
8
server.c
|
@ -35,7 +35,7 @@ vhost_lang(struct vhost *v, const char *path)
|
||||||
struct location *loc;
|
struct location *loc;
|
||||||
const char *lang = NULL;
|
const char *lang = NULL;
|
||||||
|
|
||||||
if (v == NULL)
|
if (v == NULL || path == NULL)
|
||||||
return lang;
|
return lang;
|
||||||
|
|
||||||
for (loc = v->locations; loc->match != NULL; ++loc) {
|
for (loc = v->locations; loc->match != NULL; ++loc) {
|
||||||
|
@ -54,6 +54,9 @@ vhost_default_mime(struct vhost *v, const char *path)
|
||||||
struct location *loc;
|
struct location *loc;
|
||||||
const char *default_mime = "application/octet-stream";
|
const char *default_mime = "application/octet-stream";
|
||||||
|
|
||||||
|
if (v == NULL || path == NULL)
|
||||||
|
return default_mime;
|
||||||
|
|
||||||
for (loc = v->locations; loc->match != NULL; ++loc) {
|
for (loc = v->locations; loc->match != NULL; ++loc) {
|
||||||
if (!fnmatch(loc->match, path, 0)) {
|
if (!fnmatch(loc->match, path, 0)) {
|
||||||
if (loc->default_mime != NULL)
|
if (loc->default_mime != NULL)
|
||||||
|
@ -70,6 +73,9 @@ vhost_index(struct vhost *v, const char *path)
|
||||||
struct location *loc;
|
struct location *loc;
|
||||||
const char *index = "index.gmi";
|
const char *index = "index.gmi";
|
||||||
|
|
||||||
|
if (v == NULL || path == NULL)
|
||||||
|
return index;
|
||||||
|
|
||||||
for (loc = v->locations; loc->match != NULL; ++loc) {
|
for (loc = v->locations; loc->match != NULL; ++loc) {
|
||||||
if (!fnmatch(loc->match, path, 0)) {
|
if (!fnmatch(loc->match, path, 0)) {
|
||||||
if (loc->index != NULL)
|
if (loc->index != NULL)
|
||||||
|
|
Loading…
Reference in New Issue