@@ -807,13 +807,31 @@ def read_val_generator(c_file, level, src, dest, typ, keyname, obj_typename):
807
807
c_file .write ('%s {\n ' % (' ' * (level )))
808
808
if typ .startswith ("uint" ) or \
809
809
(typ .startswith ("int" ) and typ != "integer" ) or typ == "double" :
810
- c_file .write ('%sint invalid = common_safe_%s (YAJL_GET_NUMBER (val), &%s);\n ' \
810
+ c_file .write ('%sint invalid;\n ' % (' ' * (level + 1 )))
811
+ c_file .write ('%sif (! YAJL_IS_NUMBER (val))\n ' % (' ' * (level + 1 )))
812
+ c_file .write ('%s {\n ' % (' ' * (level + 1 )))
813
+ c_file .write ('%s *err = strdup ("invalid type");\n ' % (' ' * (level + 1 )))
814
+ c_file .write ('%s return NULL;\n ' % (' ' * (level + 1 )))
815
+ c_file .write ('%s }\n ' % (' ' * (level + 1 )))
816
+ c_file .write ('%sinvalid = common_safe_%s (YAJL_GET_NUMBER (val), &%s);\n ' \
811
817
% (' ' * (level + 1 ), typ , dest ))
812
818
elif typ == "integer" :
813
- c_file .write ('%sint invalid = common_safe_int (YAJL_GET_NUMBER (val), (int *)&%s);\n ' \
819
+ c_file .write ('%sint invalid;\n ' % (' ' * (level + 1 )))
820
+ c_file .write ('%sif (! YAJL_IS_NUMBER (val))\n ' % (' ' * (level + 1 )))
821
+ c_file .write ('%s {\n ' % (' ' * (level + 1 )))
822
+ c_file .write ('%s *err = strdup ("invalid type");\n ' % (' ' * (level + 1 )))
823
+ c_file .write ('%s return NULL;\n ' % (' ' * (level + 1 )))
824
+ c_file .write ('%s }\n ' % (' ' * (level + 1 )))
825
+ c_file .write ('%sinvalid = common_safe_int (YAJL_GET_NUMBER (val), (int *)&%s);\n ' \
814
826
% (' ' * (level + 1 ), dest ))
815
827
elif typ == "UID" or typ == "GID" :
816
- c_file .write ('%sint invalid = common_safe_uint (YAJL_GET_NUMBER (val),' \
828
+ c_file .write ('%sint invalid;\n ' % (' ' * (level + 1 )))
829
+ c_file .write ('%sif (! YAJL_IS_NUMBER (val))\n ' % (' ' * (level + 1 )))
830
+ c_file .write ('%s {\n ' % (' ' * (level + 1 )))
831
+ c_file .write ('%s *err = strdup ("invalid type");\n ' % (' ' * (level + 1 )))
832
+ c_file .write ('%s return NULL;\n ' % (' ' * (level + 1 )))
833
+ c_file .write ('%s }\n ' % (' ' * (level + 1 )))
834
+ c_file .write ('%sinvalid = common_safe_uint (YAJL_GET_NUMBER (val),' \
817
835
' (unsigned int *)&%s);\n ' % (' ' * (level + 1 ), dest ))
818
836
c_file .write ('%sif (invalid)\n ' % (' ' * (level + 1 )))
819
837
c_file .write ('%s {\n ' % (' ' * (level + 1 )))
@@ -838,7 +856,13 @@ def read_val_generator(c_file, level, src, dest, typ, keyname, obj_typename):
838
856
(' ' * (level + 1 ), dest , helpers .get_map_c_types (num_type )))
839
857
c_file .write ('%sif (%s == NULL)\n ' % (' ' * (level + 1 ), dest ))
840
858
c_file .write ('%s return NULL;\n ' % (' ' * (level + 1 )))
841
- c_file .write ('%sint invalid = common_safe_%s (YAJL_GET_NUMBER (val), %s);\n ' \
859
+ c_file .write ('%sint invalid;\n ' % (' ' * (level + 1 )))
860
+ c_file .write ('%sif (! YAJL_IS_NUMBER (val))\n ' % (' ' * (level + 1 )))
861
+ c_file .write ('%s {\n ' % (' ' * (level + 1 )))
862
+ c_file .write ('%s *err = strdup ("invalid type");\n ' % (' ' * (level + 1 )))
863
+ c_file .write ('%s return NULL;\n ' % (' ' * (level + 1 )))
864
+ c_file .write ('%s}\n ' % (' ' * (level + 1 )))
865
+ c_file .write ('%sinvalid = common_safe_%s (YAJL_GET_NUMBER (val), %s);\n ' \
842
866
% (' ' * (level + 1 ), num_type , dest ))
843
867
c_file .write ('%sif (invalid)\n ' % (' ' * (level + 1 )))
844
868
c_file .write ('%s {\n ' % (' ' * (level + 1 )))
0 commit comments