Skip to content

Commit

Permalink
* Null pointer dereference fix. Fix json_object_get_boolean strlen test
Browse files Browse the repository at this point in the history
    to not return TRUE for zero length string. Remove redundant includes.
    Erik Hovland, erik at hovland dot org


git-svn-id: http://svn.metaparadigm.com/svn/json-c/trunk@31 327403b1-1117-474d-bef2-5cb71233fd97
  • Loading branch information
michaeljclark committed Feb 25, 2009
1 parent e8de078 commit 22dee7c
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
3 changes: 3 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
0.9
* Null pointer dereference fix. Fix json_object_get_boolean strlen test
to not return TRUE for zero length string. Remove redundant includes.
Erik Hovland, erik at hovland dot org
* Fixed warning reported by adding -Wstrict-prototypes
-Wold-style-definition to the compilatin flags.
Dotan Barak, dotanba at gmail dot com
Expand Down
2 changes: 1 addition & 1 deletion arraylist.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# include <string.h>
#endif /* STDC_HEADERS */

#if HAVE_STRINGS_H
#if defined HAVE_STRINGS_H && !defined _STRING_H && !defined __USE_BSD
# include <strings.h>
#endif /* HAVE_STRINGS_H */

Expand Down
3 changes: 1 addition & 2 deletions json_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include "arraylist.h"
#include "json_object.h"
#include "json_object_private.h"
#include "json_tokener.h"

#if !HAVE_STRNDUP
char* strndup(const char* str, size_t n);
Expand Down Expand Up @@ -306,7 +305,7 @@ boolean json_object_get_boolean(struct json_object *this)
case json_type_double:
return (this->o.c_double != 0);
case json_type_string:
if(strlen(this->o.c_string)) return TRUE;
return (strlen(this->o.c_string) != 0);
default:
return TRUE;
}
Expand Down
3 changes: 3 additions & 0 deletions json_tokener.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ static void json_tokener_reset_level(struct json_tokener *tok, int depth)
void json_tokener_reset(struct json_tokener *tok)
{
int i;
if (!tok)
return;

for(i = tok->depth; i >= 0; i--)
json_tokener_reset_level(tok, i);
tok->depth = 0;
Expand Down
2 changes: 0 additions & 2 deletions linkhash.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
*
*/

#include "config.h"

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
Expand Down

0 comments on commit 22dee7c

Please sign in to comment.