laurentluce/twilio-cplusplus — pull request #1 by pcolby (2014-06-02 09:27:29+00:00)
Title: Possible double-close, resulting in "undefined" behaviour.

cppcheck has correctly identified a bug in `Rest.cpp`:

```
[Rest.cpp:246]: (error) Memory pointed to by 'hd_src' is freed twice.
```

Currently, if/when `res != CURLE_OK`, then `fclose` is called twice on `hd_src` - which, according to various sources results in undefined behaviour.

> Upon successful completion 0 is returned. Otherwise, **EOF** is returned and _errno_ is set to indicate the error. In either case any further access (including another call to **fclose**()) to the stream results in undefined behavior. — [fclose(3) - Linux man page](http://linux.die.net/man/3/fclose)

This pull request fixes that issue.

Cheers.