[Live-devel] [patch] null check before dereferencing

Erik Hovland erik at hovland.org
Tue Jul 1 16:21:40 PDT 2008


In the member function SIPClient::getResponseCode the pointer
nextLineStart might be null when it is assigned to bodyStart, then
bodyStart might be used in an equation (where the calculated value will
now be off).

E

---

 liveMedia/SIPClient.cpp |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/liveMedia/SIPClient.cpp b/liveMedia/SIPClient.cpp
index a6cb8c3..91a34ef 100644
--- a/liveMedia/SIPClient.cpp
+++ b/liveMedia/SIPClient.cpp
@@ -549,7 +549,7 @@ unsigned SIPClient::getResponseCode() {
     // the "Content-length:" header (if any) that we saw.  We may need to
     // read more data, or we may have extraneous data in the buffer.
     char* bodyStart = nextLineStart;
-    if (contentLength >= 0) {
+    if (bodyStart != NULL && contentLength >= 0) {
       // We saw a "Content-length:" header
       unsigned numBodyBytes = &readBuf[bytesRead] - bodyStart;
       if (contentLength > (int)numBodyBytes) {
-- 
Erik Hovland
mail: erik at hovland.org
web: http://hovland.org/
PGP/GPG public key available on request



More information about the live-devel mailing list