Bug 1280283 - Fix uchex warnings about null-check after pointer deref in webrtc/signaling. r=drno
authorChris Peterson <cpeterson@mozilla.com>
Wed, 15 Jun 2016 17:19:29 +0100
changeset 301986 6cdb479ad755a4904c20f540ad4af83d7003de4e
parent 301985 a12f445c45d1f41ade8e4fe230893381b4dffa99
child 301987 45fa8083c4fc6e4279125fedbcec061657b64107
push id19704
push usercbook@mozilla.com
push dateFri, 17 Jun 2016 00:03:56 +0000
treeherderfx-team@5f95858f8ddf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdrno
bugs1280283
milestone50.0a1
Bug 1280283 - Fix uchex warnings about null-check after pointer deref in webrtc/signaling. r=drno
media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c
--- a/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c
+++ b/media/webrtc/signaling/src/sdp/sipcc/sdp_utils.c
@@ -57,24 +57,27 @@ sdp_mca_t *sdp_alloc_mca (uint32_t line)
  * copy token param with chars from str until null, cr, lf, or one of the delimiters is found.
  * delimiters at the beginning will be skipped.
  * The pointer *string_of_tokens is moved forward to the next token on sucess.
  *
  */
 static sdp_result_e next_token(const char **string_of_tokens, char *token, unsigned token_max_len, const char *delim)
 {
   int flag2moveon = 0;
-  const char *str = *string_of_tokens;
-  const char *token_end = token + token_max_len - 1;
+  const char *str;
+  const char *token_end;
   const char *next_delim;
 
   if (!string_of_tokens || !*string_of_tokens || !token || !delim) {
     return SDP_FAILURE;
   }
 
+  str = *string_of_tokens;
+  token_end = token + token_max_len - 1;
+
   /* Locate front of token, skipping any delimiters */
   for ( ; ((*str != '\0') && (*str != '\n') && (*str != '\r')); str++) {
     flag2moveon = 1;  /* Default to move on unless we find a delimiter */
     for (next_delim=delim; *next_delim; next_delim++) {
       if (*str == *next_delim) {
         flag2moveon = 0;
         break;
       }
@@ -345,17 +348,19 @@ uint32_t sdp_getnextnumtok_or_null (cons
                                const char *delim, tinybool *null_ind,
                                sdp_result_e *result)
 {
   const char *token_list = str;
   char temp_token[SDP_MAX_STRING_LEN];
   char *strtoul_end;
   unsigned long numval;
 
-  *null_ind = FALSE;
+  if (null_ind) {
+    *null_ind = FALSE;
+  }
 
   if (!str || !str_end || !delim || !null_ind || !result) {
     if (result) {
       *result = SDP_FAILURE;
     }
     return 0;
   }