Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c0aab89

Browse files
committed
Added some error checks.
1 parent a76fb5b commit c0aab89

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

Modules/almodule.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,8 +423,13 @@ al_openport (self, args)
423423
object *name, *dir;
424424
ALport port;
425425
ALconfig config = NULL;
426-
int size = gettuplesize(args);
426+
int size;
427427

428+
if (args == NULL || !is_tupleobject(args)) {
429+
err_badarg();
430+
return NULL;
431+
}
432+
size = gettuplesize(args);
428433
if (size == 2) {
429434
if (!getstrstrarg (args, &name, &dir))
430435
return NULL;
@@ -440,6 +445,11 @@ al_openport (self, args)
440445

441446
port = ALopenport(getstringvalue(name), getstringvalue(dir), config);
442447

448+
if (port == NULL) {
449+
err_errno(RuntimeError);
450+
return NULL;
451+
}
452+
443453
return newportobject (port);
444454
}
445455

@@ -452,6 +462,10 @@ al_newconfig (self, args)
452462
if (!getnoarg (args)) return NULL;
453463

454464
config = ALnewconfig ();
465+
if (config == NULL) {
466+
err_errno(RuntimeError);
467+
return NULL;
468+
}
455469

456470
return newconfigobject (config);
457471
}
@@ -523,6 +537,8 @@ doParams(args, func, modified)
523537
setlistitem(list, i, newintobject(PVbuffer[i]));
524538
}
525539

540+
DEL(PVbuffer);
541+
526542
INCREF(None);
527543
return None;
528544
}

0 commit comments

Comments
 (0)