Patch 8.0.0216
Problem:    When decoding JSON with a JS style object the JSON test may use a
            NULL pointer. (Coverity)
Solution:   Check for a NULL pointer.
Files:      src/json.c, src/json_test.c


*** ../vim-8.0.0215/src/json.c  2017-01-14 14:36:03.225775105 +0100
--- src/json.c  2017-01-22 15:52:55.897834553 +0100
***************
*** 629,638 ****
            key = p = reader->js_buf + reader->js_used;
            while (*p != NUL && *p != ':' && *p > ' ')
                ++p;
!           cur_item->v_type = VAR_STRING;
!           cur_item->vval.v_string = vim_strnsave(key, (int)(p - key));
            reader->js_used += (int)(p - key);
-           top_item->jd_key = cur_item->vval.v_string;
        }
        else
        {
--- 629,641 ----
            key = p = reader->js_buf + reader->js_used;
            while (*p != NUL && *p != ':' && *p > ' ')
                ++p;
!           if (cur_item != NULL)
!           {
!               cur_item->v_type = VAR_STRING;
!               cur_item->vval.v_string = vim_strnsave(key, (int)(p - key));
!               top_item->jd_key = cur_item->vval.v_string;
!           }
            reader->js_used += (int)(p - key);
        }
        else
        {
***************
*** 1053,1059 ****
  
  /*
   * Decode the JSON from "reader" to find the end of the message.
!  * "options" can be JSON_JS or zero;
   * Return FAIL if the message has a decoding error.
   * Return MAYBE if the message is truncated, need to read more.
   * This only works reliable if the message contains an object, array or
--- 1056,1063 ----
  
  /*
   * Decode the JSON from "reader" to find the end of the message.
!  * "options" can be JSON_JS or zero.
!  * This is only used for testing.
   * Return FAIL if the message has a decoding error.
   * Return MAYBE if the message is truncated, need to read more.
   * This only works reliable if the message contains an object, array or
*** ../vim-8.0.0215/src/json_test.c     2017-01-11 21:50:04.884673277 +0100
--- src/json_test.c     2017-01-22 15:48:50.959384783 +0100
***************
*** 107,112 ****
--- 107,118 ----
      reader.js_buf = (char_u *)"  {   ";
      assert(json_find_end(&reader, 0) == MAYBE);
  
+     /* JS object with white space */
+     reader.js_buf = (char_u *)"  {  a  :  123  }  ";
+     assert(json_find_end(&reader, JSON_JS) == OK);
+     reader.js_buf = (char_u *)"  {  a  :   ";
+     assert(json_find_end(&reader, JSON_JS) == MAYBE);
+ 
      /* array without white space */
      reader.js_buf = (char_u *)"[\"a\",123]";
      assert(json_find_end(&reader, 0) == OK);
*** ../vim-8.0.0215/src/version.c       2017-01-22 15:39:57.170763849 +0100
--- src/version.c       2017-01-22 15:50:42.146681048 +0100
***************
*** 766,767 ****
--- 766,769 ----
  {   /* Add new patch number below this line */
+ /**/
+     216,
  /**/

-- 
You got to work at a mill?  Lucky!  I got sent back to work in the
acid-mines for my daily crust of stale bread... which not even the
birds would eat.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui