c - segmentation fault on g_string_truncate ()? -
when trying following in c :
g_string_printf(qbuf,"insert inbox (number, smsdate, text) values ('%s','%04d-%02d-%02d %02d:%02d:%02d', '%s')", xmx.remote.number, xmx.smsc_time.year, xmx.smsc_time.month, xmx.smsc_time.day, xmx.smsc_time.hour, xmx.smsc_time.minute, xmx.smsc_time.second, xmx.user_data[0].u.text);
i see following crash:
program received signal sigsegv, segmentation fault. 0x00984809 in g_string_truncate () /lib/libglib-2.0.so.0 (gdb)
why happen? there initiation before calling g_string_printf() ?
from frame 2:
(gdb) frame 2 #2 0x08049ba8 in fetching_phone (unit=0x807cd80) @ main.c:152 152 g_string_printf(qbuf,"insert inbox (number, smsdate, text) values ('%s','%04d-%02d-%02d %02d:%02d:%02d', '%s')", (gdb) ptype xmx.remote.number type = char [40] (gdb) ptype xmx.smsc_time.year type = int (gdb) ptype xmx.smsc_time.month type = int (gdb) ptype xmx.smsc_time.day type = int (gdb) ptype xmx.smsc_time.hour type = int (gdb) ptype xmx.smsc_time.minute type = int (gdb) ptype xmx.smsc_time.second type = int (gdb) ptype xmx.user_data[0].u.text type = unsigned char [1601] (gdb)
but, still can't find problem is.
did initialize qbuf
?
gstring *qbuf = g_string_new("");
Comments
Post a Comment