Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for 64bit compilation #45

Open
wants to merge 6 commits into from

4 participants

Jean-Charles BERTIN Mikko Lehtonen Joey Ekstrom Giuseppe Valente
Jean-Charles BERTIN

After compiling for 64bit target with full warnings enabled, I got some warnings. Also, with LLVM 3.0 static analyzer, I found more problems. Last, I found a bug in DECREMENT_DEPTH which returns wrong status code (yajl_gen_state instead of yajl_gen_status).

Hope this will help. Regards.

Jean-Charles BERTIN

I think that patch c926e05 is a better approach for issue #34 than pull request #43: adding a symbolic link to the existing include folder doesn't change the project structure.

Regards.

jcekstrom and others added some commits
Joey Ekstrom jcekstrom Fixed a bug where valid integers were not being flagged as such, making
calls like YAJL_IS_INTEGER fail, even though parsing succeeded.
Consisted of removing checks that would have been necessary, if the
custom integer parsing wasn't used.
fca04a8
Giuseppe Valente 7AC added errno resetting before setting/checking it in yajl_do_parse() 914936c
Jean-Charles BERTIN

I think also that changing yajl_parse_integer() prototype in b3a1e0b is a better way for fixing warnings than 0420747 in pull request #31.

Regards.

Mikko Lehtonen

I'm unsure how symbolic links are supported on windows, or in other scm systems where one might want to embed all of the external deps, so I'm kinda against them. But it's not my call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 5, 2011
  1. Jean-Charles BERTIN
  2. Jean-Charles BERTIN
  3. Jean-Charles BERTIN
  4. Jean-Charles BERTIN
Commits on Jul 8, 2011
  1. Joey Ekstrom Jean-Charles BERTIN

    Fixed a bug where valid integers were not being flagged as such, making

    jcekstrom authored jcbertin committed
    calls like YAJL_IS_INTEGER fail, even though parsing succeeded.
    Consisted of removing checks that would have been necessary, if the
    custom integer parsing wasn't used.
  2. Giuseppe Valente Jean-Charles BERTIN
This page is out of date. Refresh to see the latest.
1  include/yajl
View
2  src/yajl_gen.c
View
@@ -171,7 +171,7 @@ yajl_gen_free(yajl_gen g)
if (++(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded;
#define DECREMENT_DEPTH \
- if (--(g->depth) >= YAJL_MAX_DEPTH) return yajl_gen_error;
+ if (--(g->depth) >= YAJL_MAX_DEPTH) return yajl_max_depth_exceeded;
#define APPENDED_ATOM \
switch (g->state[g->depth]) { \
5 src/yajl_lex.c
View
@@ -626,8 +626,11 @@ yajl_lex_lex(yajl_lexer lexer, const unsigned char * jsonText,
jsonTextLen, offset);
if (tok == yajl_tok_comment) {
/* "error" is silly, but that's the initial
- * state of tok. guilty until proven innocent. */
+ * state of tok. guilty until proven innocent. */
+#if 0
+ /* Static analyser says that it is innocent */
tok = yajl_tok_error;
+#endif
yajl_buf_clear(lexer->buf);
lexer->bufInUse = 0;
startOffset = *offset;
4 src/yajl_parser.c
View
@@ -33,7 +33,7 @@
/* same semantics as strtol */
long long
-yajl_parse_integer(const unsigned char *number, unsigned int length)
+yajl_parse_integer(const unsigned char *number, size_t length)
{
long long ret = 0;
long sign = 1;
@@ -279,6 +279,7 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText,
hand->ctx,(const char *) buf, bufLen));
} else if (hand->callbacks->yajl_integer) {
long long int i = 0;
+ errno = 0;
i = yajl_parse_integer(buf, bufLen);
if ((i == LLONG_MIN || i == LLONG_MAX) &&
errno == ERANGE)
@@ -306,6 +307,7 @@ yajl_do_parse(yajl_handle hand, const unsigned char * jsonText,
yajl_buf_clear(hand->decodeBuf);
yajl_buf_append(hand->decodeBuf, buf, bufLen);
buf = yajl_buf_data(hand->decodeBuf);
+ errno = 0;
d = strtod((char *) buf, NULL);
if ((d == HUGE_VAL || d == -HUGE_VAL) &&
errno == ERANGE)
2  src/yajl_parser.h
View
@@ -72,7 +72,7 @@ yajl_render_error_string(yajl_handle hand, const unsigned char * jsonText,
/* A little built in integer parsing routine with the same semantics as strtol
* that's unaffected by LOCALE. */
long long
-yajl_parse_integer(const unsigned char *number, unsigned int length);
+yajl_parse_integer(const unsigned char *number, size_t length);
#endif
41 src/yajl_tree.c
View
@@ -260,12 +260,17 @@ static int context_add_value (context_t *ctx, yajl_val v)
{
return (array_add_value (ctx, ctx->stack->value, v));
}
- else
+ else if (ctx->stack->value != NULL)
{
RETURN_ERROR (ctx, EINVAL, "context_add_value: Cannot add value to "
"a value of type %#04x (not a composite type)",
ctx->stack->value->type);
}
+ else
+ {
+ RETURN_ERROR (ctx, EINVAL, "context_add_value: Cannot add value to "
+ "NULL value");
+ }
}
static int handle_string (void *ctx,
@@ -309,11 +314,10 @@ static int handle_number (void *ctx, const char *string, size_t string_length)
v->u.number.flags = 0;
- endptr = NULL;
errno = 0;
v->u.number.i = yajl_parse_integer((const unsigned char *) v->u.number.r,
strlen(v->u.number.r));
- if ((errno == 0) && (endptr != NULL) && (*endptr == 0))
+ if (errno == 0)
v->u.number.flags |= YAJL_NUMBER_INT_VALID;
endptr = NULL;
@@ -435,29 +439,34 @@ yajl_val yajl_tree_parse (const char *input,
status = yajl_parse(handle,
(unsigned char *) input,
strlen (input));
+ if (status != yajl_status_ok)
+ goto error;
+
status = yajl_complete_parse (handle);
- if (status != yajl_status_ok) {
- if (error_buffer != NULL && error_buffer_size > 0) {
- snprintf(
- error_buffer, error_buffer_size, "%s",
- (char *) yajl_get_error(handle, 1,
- (const unsigned char *) input,
- strlen(input)));
- }
- yajl_free (handle);
- return NULL;
- }
+ if (status != yajl_status_ok)
+ goto error;
yajl_free (handle);
return (ctx.root);
+
+error:
+ if (error_buffer != NULL && error_buffer_size > 0) {
+ snprintf(
+ error_buffer, error_buffer_size, "%s",
+ (char *) yajl_get_error(handle, 1,
+ (const unsigned char *) input,
+ strlen(input)));
+ }
+ yajl_free (handle);
+ return NULL;
}
yajl_val yajl_tree_get(yajl_val n, const char ** path, yajl_type type)
{
if (!path) return NULL;
while (n && *path) {
- unsigned int i;
- int len;
+ size_t i;
+ size_t len;
if (n->type != yajl_t_object) return NULL;
len = n->u.object.len;
Something went wrong with that request. Please try again.