mirror of
https://github.com/adnanh/webhook.git
synced 2025-05-17 11:00:09 +00:00
Merge pull request #212 from adnanh/fix-file-panic
Fix nilpointer dereference when file cannot be created
This commit is contained in:
commit
357c471667
1 changed files with 4 additions and 1 deletions
|
@ -23,7 +23,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
version = "2.6.7"
|
version = "2.6.8"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -368,13 +368,16 @@ func handleHook(h *hook.Hook, rid string, headers, query, payload *map[string]in
|
||||||
tmpfile, err := ioutil.TempFile(h.CommandWorkingDirectory, files[i].EnvName)
|
tmpfile, err := ioutil.TempFile(h.CommandWorkingDirectory, files[i].EnvName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("[%s] error creating temp file [%s]", rid, err)
|
log.Printf("[%s] error creating temp file [%s]", rid, err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
log.Printf("[%s] writing env %s file %s", rid, files[i].EnvName, tmpfile.Name())
|
log.Printf("[%s] writing env %s file %s", rid, files[i].EnvName, tmpfile.Name())
|
||||||
if _, err := tmpfile.Write(files[i].Data); err != nil {
|
if _, err := tmpfile.Write(files[i].Data); err != nil {
|
||||||
log.Printf("[%s] error writing file %s [%s]", rid, tmpfile.Name(), err)
|
log.Printf("[%s] error writing file %s [%s]", rid, tmpfile.Name(), err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
if err := tmpfile.Close(); err != nil {
|
if err := tmpfile.Close(); err != nil {
|
||||||
log.Printf("[%s] error closing file %s [%s]", rid, tmpfile.Name(), err)
|
log.Printf("[%s] error closing file %s [%s]", rid, tmpfile.Name(), err)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
files[i].File = tmpfile
|
files[i].File = tmpfile
|
||||||
|
|
Loading…
Add table
Reference in a new issue