]> granicus.if.org Git - curl/commitdiff
Curl_rtsp_parseheader: avoid useless malloc/free
authorDaniel Stenberg <daniel@haxx.se>
Fri, 15 Jun 2012 20:51:45 +0000 (22:51 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 15 Jun 2012 20:51:45 +0000 (22:51 +0200)
Coverity actually pointed out flawed logic in the previous call to
Curl_strntoupper() where the code used sizeof() of a pointer to pass in
a size argument. That code still worked since it only needed to
uppercase 4 letters. Still, the entire malloc/uppercase/free sequence
was pointless since the code has already matched the string once in the
condition that starts the block of code.

lib/rtsp.c

index 5d62ac7c7518058f8b1fb567f38631d61dc5db15..ca9788ef78bb8f94c1d27184171edcb01fc90de9 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -747,13 +747,7 @@ CURLcode Curl_rtsp_parseheader(struct connectdata *conn,
 
   if(checkprefix("CSeq:", header)) {
     /* Store the received CSeq. Match is verified in rtsp_done */
-    int nc;
-    char *temp = strdup(header);
-    if(!temp)
-      return CURLE_OUT_OF_MEMORY;
-    Curl_strntoupper(temp, temp, sizeof(temp));
-    nc = sscanf(temp, "CSEQ: %ld", &CSeq);
-    free(temp);
+    int nc = sscanf(&header[4], ": %ld", &CSeq);
     if(nc == 1) {
       data->state.proto.rtsp->CSeq_recv = CSeq; /* mark the request */
       data->state.rtsp_CSeq_recv = CSeq; /* update the handle */