Menu

cJSON_CreateBool bug?

Help
2014-05-06
2014-05-06
  • Marcos Kirsch

    Marcos Kirsch - 2014-05-06

    Unless I understand correctly, the intended behavior is that if the client passes 0, a false is created, else a true.

    This is the implementation provided (reformatted for readability):

    cJSON cJSON_CreateBool(int b)
    {
    cJSON
    item=cJSON_New_Item();
    if(item)item->type=b?cJSON_True:cJSON_False;
    return item;
    }

    This is the implementation it should have:

    cJSON cJSON_CreateBool(int b)
    {
    cJSON
    item=cJSON_New_Item();
    if(item)item->type=(b?cJSON_True:cJSON_False);
    return item;
    }

    ... it's missing the parenthesis, so it assigns b to item->type.

     
  • Marcos Kirsch

    Marcos Kirsch - 2014-05-06

    I apologize, I have now filed a bug for this: https://sourceforge.net/p/cjson/bugs/39/

     

Log in to post a comment.