1、When I run the address program under the databinding directory and input relevant information, the Segmentation fault is reported, and the printed information of gdb debugging is as follows:
(gdb) r
Starting program: /home/alnin/gsoap/linux/gsoap-2.8-armeabi-v7a-build/gsoap/samples/databinding/address
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
ADDRESS BOOK - An Example XML Data Binding Application
Enter a new contact:
Name > alnin
Street > donghu
City > wuhan
Zip > 430000
Country > us
Phone > 13144842767
Mobile > 84233396
DOB > 569710150
Program received signal SIGSEGV, Segmentation fault.
soap_s2dateTime (soap=0x7ffff7a2a010, s=0x55555559e3a0 <user_input(char const*)::buf=""> "569710150", p=0x0) at stdsoap2_cpp.cpp:19340
19340 *p = 0;
(gdb)</user_input(char>
2、It shows that p is a null pointer, and nowhere else is there any allocation of dynamic memory, such as in the following statement:
// 在堆上分配一个 time_t 变量并初始化
time_t *p = new time_t(time(nullptr));
Could you please help to see if this is a problem? If it's not a problem, what can I do to make the program run without error? Thank you.
Thanks for reporting. The address.cpp demo example application has a missing allocation for the DOB field. The code that takes the DOB in address.cpp:166 should be:
Otherwise,
a->dob
is null and that leads to the problem.