Hi.
While trying this library, I found that the pointer Variant can only be initialized using internalSetPtr() method call.
However, it is still possible to create an uninitialized pointer Variant through Variant(Type) constructor which could lead the program to crash when it is dereferenced, as shown in the following code snippet.
#include "var.h"
int main() {
jvar::Variant variant3(jvar::Variant::Type::V_POINTER); // illegal
variant3.toJsonString(); // crash
}
Do you think it's worth preventing such crashes by disallowing uninitialized pointer-type Variant creation from the Variant(Type) constructor? I think the library would be safer if the library forces the users to construct such pointer Variant only by calling internalSetPtr(...) explicitly, for example:
#include "var.h"
int main() {
jvar::Variant variant3; // empty variant first
variant3.internalSetPtr(...); // initializes pointer variant
variant3.toJsonString();
}
CMIIW.
Thank you.
Hi.
While trying this library, I found that the pointer
Variantcan only be initialized usinginternalSetPtr()method call.However, it is still possible to create an uninitialized pointer
VariantthroughVariant(Type)constructor which could lead the program to crash when it is dereferenced, as shown in the following code snippet.Do you think it's worth preventing such crashes by disallowing uninitialized pointer-type
Variantcreation from theVariant(Type)constructor? I think the library would be safer if the library forces the users to construct such pointerVariantonly by callinginternalSetPtr(...)explicitly, for example:CMIIW.
Thank you.