@@ -229,6 +229,7 @@ get_char_item(int lineno, void *var, enum ECPGttype vartype, char *value, int va
229
229
230
230
#define RETURN_IF_NO_DATA if (ntuples < 1) \
231
231
{ \
232
+ va_end(args); \
232
233
ecpg_raise(lineno, ECPG_NOT_FOUND, ECPG_SQLSTATE_NO_DATA, NULL); \
233
234
return (false); \
234
235
}
@@ -248,13 +249,17 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
248
249
ecpg_init_sqlca (sqlca );
249
250
ECPGresult = ecpg_result_by_descriptor (lineno , desc_name );
250
251
if (!ECPGresult )
252
+ {
253
+ va_end (args );
251
254
return (false);
255
+ }
252
256
253
257
ntuples = PQntuples (ECPGresult );
254
258
255
259
if (index < 1 || index > PQnfields (ECPGresult ))
256
260
{
257
261
ecpg_raise (lineno , ECPG_INVALID_DESCRIPTOR_INDEX , ECPG_SQLSTATE_INVALID_DESCRIPTOR_INDEX , NULL );
262
+ va_end (args );
258
263
return (false);
259
264
}
260
265
@@ -312,68 +317,98 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
312
317
313
318
case ECPGd_name :
314
319
if (!get_char_item (lineno , var , vartype , PQfname (ECPGresult , index ), varcharsize ))
320
+ {
321
+ va_end (args );
315
322
return (false);
323
+ }
316
324
317
325
ecpg_log ("ECPGget_desc: NAME = %s\n" , PQfname (ECPGresult , index ));
318
326
break ;
319
327
320
328
case ECPGd_nullable :
321
329
if (!get_int_item (lineno , var , vartype , 1 ))
330
+ {
331
+ va_end (args );
322
332
return (false);
333
+ }
323
334
324
335
break ;
325
336
326
337
case ECPGd_key_member :
327
338
if (!get_int_item (lineno , var , vartype , 0 ))
339
+ {
340
+ va_end (args );
328
341
return (false);
342
+ }
329
343
330
344
break ;
331
345
332
346
case ECPGd_scale :
333
347
if (!get_int_item (lineno , var , vartype , (PQfmod (ECPGresult , index ) - VARHDRSZ ) & 0xffff ))
348
+ {
349
+ va_end (args );
334
350
return (false);
351
+ }
335
352
336
353
ecpg_log ("ECPGget_desc: SCALE = %d\n" , (PQfmod (ECPGresult , index ) - VARHDRSZ ) & 0xffff );
337
354
break ;
338
355
339
356
case ECPGd_precision :
340
357
if (!get_int_item (lineno , var , vartype , PQfmod (ECPGresult , index ) >> 16 ))
358
+ {
359
+ va_end (args );
341
360
return (false);
361
+ }
342
362
343
363
ecpg_log ("ECPGget_desc: PRECISION = %d\n" , PQfmod (ECPGresult , index ) >> 16 );
344
364
break ;
345
365
346
366
case ECPGd_octet :
347
367
if (!get_int_item (lineno , var , vartype , PQfsize (ECPGresult , index )))
368
+ {
369
+ va_end (args );
348
370
return (false);
371
+ }
349
372
350
373
ecpg_log ("ECPGget_desc: OCTET_LENGTH = %d\n" , PQfsize (ECPGresult , index ));
351
374
break ;
352
375
353
376
case ECPGd_length :
354
377
if (!get_int_item (lineno , var , vartype , PQfmod (ECPGresult , index ) - VARHDRSZ ))
378
+ {
379
+ va_end (args );
355
380
return (false);
381
+ }
356
382
357
383
ecpg_log ("ECPGget_desc: LENGTH = %d\n" , PQfmod (ECPGresult , index ) - VARHDRSZ );
358
384
break ;
359
385
360
386
case ECPGd_type :
361
387
if (!get_int_item (lineno , var , vartype , ecpg_dynamic_type (PQftype (ECPGresult , index ))))
388
+ {
389
+ va_end (args );
362
390
return (false);
391
+ }
363
392
364
393
ecpg_log ("ECPGget_desc: TYPE = %d\n" , ecpg_dynamic_type (PQftype (ECPGresult , index )));
365
394
break ;
366
395
367
396
case ECPGd_di_code :
368
397
if (!get_int_item (lineno , var , vartype , ecpg_dynamic_type_DDT (PQftype (ECPGresult , index ))))
398
+ {
399
+ va_end (args );
369
400
return (false);
401
+ }
370
402
371
403
ecpg_log ("ECPGget_desc: TYPE = %d\n" , ecpg_dynamic_type_DDT (PQftype (ECPGresult , index )));
372
404
break ;
373
405
374
406
case ECPGd_cardinality :
375
407
if (!get_int_item (lineno , var , vartype , PQntuples (ECPGresult )))
408
+ {
409
+ va_end (args );
376
410
return (false);
411
+ }
377
412
378
413
ecpg_log ("ECPGget_desc: CARDINALITY = %d\n" , PQntuples (ECPGresult ));
379
414
break ;
@@ -391,6 +426,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
391
426
ecpg_log ("ECPGget_desc on line %d: incorrect number of matches; %d don't fit into array of %ld\n" ,
392
427
lineno , ntuples , arrsize );
393
428
ecpg_raise (lineno , ECPG_TOO_MANY_MATCHES , ECPG_SQLSTATE_CARDINALITY_VIOLATION , NULL );
429
+ va_end (args );
394
430
return false;
395
431
}
396
432
/* allocate storage if needed */
@@ -399,7 +435,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
399
435
void * mem = (void * ) ecpg_alloc (offset * ntuples , lineno );
400
436
401
437
if (!mem )
438
+ {
439
+ va_end (args );
402
440
return false;
441
+ }
403
442
* (void * * ) var = mem ;
404
443
ecpg_add_mem (mem , lineno );
405
444
var = mem ;
@@ -408,7 +447,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
408
447
for (act_tuple = 0 ; act_tuple < ntuples ; act_tuple ++ )
409
448
{
410
449
if (!get_int_item (lineno , var , vartype , PQgetlength (ECPGresult , act_tuple , index )))
450
+ {
451
+ va_end (args );
411
452
return (false);
453
+ }
412
454
var = (char * ) var + offset ;
413
455
ecpg_log ("ECPGget_desc: RETURNED[%d] = %d\n" , act_tuple , PQgetlength (ECPGresult , act_tuple , index ));
414
456
}
@@ -417,6 +459,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
417
459
default :
418
460
snprintf (type_str , sizeof (type_str ), "%d" , type );
419
461
ecpg_raise (lineno , ECPG_UNKNOWN_DESCRIPTOR_ITEM , ECPG_SQLSTATE_ECPG_INTERNAL_ERROR , type_str );
462
+ va_end (args );
420
463
return (false);
421
464
}
422
465
@@ -460,6 +503,7 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
460
503
ecpg_log ("ECPGget_desc on line %d: incorrect number of matches (indicator); %d don't fit into array of %ld\n" ,
461
504
lineno , ntuples , data_var .ind_arrsize );
462
505
ecpg_raise (lineno , ECPG_TOO_MANY_MATCHES , ECPG_SQLSTATE_CARDINALITY_VIOLATION , NULL );
506
+ va_end (args );
463
507
return false;
464
508
}
465
509
@@ -469,7 +513,10 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
469
513
void * mem = (void * ) ecpg_alloc (data_var .ind_offset * ntuples , lineno );
470
514
471
515
if (!mem )
516
+ {
517
+ va_end (args );
472
518
return false;
519
+ }
473
520
* (void * * ) data_var .ind_pointer = mem ;
474
521
ecpg_add_mem (mem , lineno );
475
522
data_var .ind_value = mem ;
@@ -478,12 +525,16 @@ ECPGget_desc(int lineno, const char *desc_name, int index,...)
478
525
for (act_tuple = 0 ; act_tuple < ntuples ; act_tuple ++ )
479
526
{
480
527
if (!get_int_item (lineno , data_var .ind_value , data_var .ind_type , - PQgetisnull (ECPGresult , act_tuple , index )))
528
+ {
529
+ va_end (args );
481
530
return (false);
531
+ }
482
532
data_var .ind_value = (char * ) data_var .ind_value + data_var .ind_offset ;
483
533
ecpg_log ("ECPGget_desc: INDICATOR[%d] = %d\n" , act_tuple , - PQgetisnull (ECPGresult , act_tuple , index ));
484
534
}
485
535
}
486
536
sqlca -> sqlerrd [2 ] = ntuples ;
537
+ va_end (args );
487
538
return (true);
488
539
}
489
540
@@ -575,6 +626,7 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
575
626
if (!ecpg_store_input (lineno , true, var , & tobeinserted , false))
576
627
{
577
628
ecpg_free (var );
629
+ va_end (args );
578
630
return false;
579
631
}
580
632
@@ -612,11 +664,13 @@ ECPGset_desc(int lineno, const char *desc_name, int index,...)
612
664
snprintf (type_str , sizeof (type_str ), "%d" , itemtype );
613
665
ecpg_raise (lineno , ECPG_UNKNOWN_DESCRIPTOR_ITEM , ECPG_SQLSTATE_ECPG_INTERNAL_ERROR , type_str );
614
666
ecpg_free (var );
667
+ va_end (args );
615
668
return false;
616
669
}
617
670
}
618
671
}
619
672
ecpg_free (var );
673
+ va_end (args );
620
674
621
675
return true;
622
676
}
0 commit comments