mirror of
https://github.com/FluuxIO/go-xmpp.git
synced 2026-05-06 13:12:55 -07:00
Fix SIGSEGV in xmpp_component (#126)
* SIGSEGV in xmpp_component example with Prosody #126
This commit is contained in:
committed by
Jérôme Sautret
parent
6aa1e668ee
commit
7d89353156
@@ -7,9 +7,8 @@ import (
|
||||
"encoding/xml"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
|
||||
"gosrc.io/xmpp/stanza"
|
||||
"io"
|
||||
)
|
||||
|
||||
type ComponentOptions struct {
|
||||
@@ -50,7 +49,6 @@ type Component struct {
|
||||
|
||||
// read / write
|
||||
socketProxy io.ReadWriter // TODO
|
||||
decoder *xml.Decoder
|
||||
}
|
||||
|
||||
func NewComponent(opts ComponentOptions, r *Router) (*Component, error) {
|
||||
@@ -90,7 +88,7 @@ func (c *Component) Resume(sm SMState) error {
|
||||
}
|
||||
|
||||
// Check server response for authentication
|
||||
val, err := stanza.NextPacket(c.decoder)
|
||||
val, err := stanza.NextPacket(c.transport.GetDecoder())
|
||||
if err != nil {
|
||||
c.updateState(StatePermanentError)
|
||||
return NewConnError(err, true)
|
||||
@@ -125,7 +123,7 @@ func (c *Component) SetHandler(handler EventHandler) {
|
||||
// Receiver Go routine receiver
|
||||
func (c *Component) recv() (err error) {
|
||||
for {
|
||||
val, err := stanza.NextPacket(c.decoder)
|
||||
val, err := stanza.NextPacket(c.transport.GetDecoder())
|
||||
if err != nil {
|
||||
c.updateState(StateDisconnected)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user